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
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.
ByPhoenix
ByPhoenix 2017-5-21
Ty Jan, code is now runable, "dongu"---->loops "cubukuzunluk"---->the length of seesaw arms ""dikdegisx""----> tryed something with angles but thats not important

请先登录,再进行评论。

采纳的回答

MathReallyWorks
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 个)

类别

Help CenterFile Exchange 中查找有关 Animation 的更多信息

标签

尚未输入任何标签。

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by