Plotting Animation Help Needed
1 回表示 (過去 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!