Plotting Animation Help Needed
조회 수: 2 (최근 30일)
이전 댓글 표시
Hello guys first of all, i need to plot a seesaw like can be seen below with red and i need to move it like the blue one;
- _ Code Fixed and now can runable_*
Here is what i done so far but its not works like i want
cubukuzunluk = 800;
x1uzak=300;
y1uzak=50;
dongu = 90;
dongu2=dongu;
tana=0;
alfa=0;
degisy=0;
dikdegisx=0;
yukselme=0;
F(dongu) = struct('cdata',[],'colormap',[]);
for j = 1:dongu
clf
axis([-cubukuzunluk/2-100 cubukuzunluk/2+100 -50 250])
superhesaplamalar= j +5;
if j < dikdegisx
yukselme = j
end
hold on
plot([-50,50,-50,0,0,50],[0,0,0,100,100,0])
hold on
%sağa eğilme
plot([cubukuzunluk/2,-cubukuzunluk/2],[100-superhesaplamalar,100+superhesaplamalar])
%sola eğilme
%plot([250,-150],[100+superhesaplamalar,100-superhesaplamalar])
hold on
%kutu 1 çiz sol tarafa
plot([-x1uzak-25,-x1uzak+25,-x1uzak+25,-x1uzak-25,-x1uzak-25],[150+superhesaplamalar,150+superhesaplamalar,100+superhesaplamalar,100+superhesaplamalar,150+superhesaplamalar])
drawnow
F(j) = getframe;
end
댓글 수: 2
Jan
2017년 5월 21일
We cannot run your code, e.g. because "dongu", "cubukuzunluk" and "dikdegisx" is undefined. You do not explain, what is not working as expected and the 2 images do not clarify exactly what you want. I do not see a chance to guess, how your code should be changed to satisfy your need.
Please post details. Do this by editing the question, not by adding a comment or answer.
채택된 답변
MathReallyWorks
2017년 5월 21일
편집: MathReallyWorks
2017년 5월 21일
Hello Dear,
Use this code. If you want make necessary changes as per your requirements.
clc;
close all;
clear all;
axis([-2 12 -5 5])
xt = [1 0 0 1];
yt = [1 1 0 0];
hold on
t = area(xt,yt);
hold off
disp('Do you want the object to slide?');
ip=input('1. Yes 2. No');
if ip==1
figure,
axis([-2 12 -5 5])
xlabel('X data')
ylabel('Y data')
zlabel('Z data')
legend('Data A','Data B')
%grid on
az = 0;
el = 90;
view([az,el])
degStep = 45;
detlaT = 0.1;
fCount = 71;
f = getframe(gcf);
[im,map] = rgb2ind(f.cdata,256,'nodither');
im(1,1,1,fCount) = 0;
k = 1;
% spin 45°
for i = 0:degStep:45
az = i;
view([az,el])
f = getframe(gcf);
im(:,:,1,k) = rgb2ind(f.cdata,map,'nodither');
k = k + 1;
end
xt = [1 0 0 1];
yt = [1 1 0 0];
hold on
t = area(xt,yt);
hold off
for j = 1:0.01:10
xt(1) = xt(1)+0.01;
xt(2) = xt(2)+0.01;
xt(3) = xt(3)+0.01;
xt(4) = xt(4)+0.01;
t.XData = xt;
t.YData = yt;
drawnow limitrate
end
end
If you want a clear description of all the steps involved in this code. Check the full descriptive code here: Sliding Box Animation
댓글 수: 0
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Animation에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!