Effacer les filtres
Effacer les filtres

Plotting Animation Help Needed

2 vues (au cours des 30 derniers jours)
ByPhoenix
ByPhoenix le 20 Mai 2017
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 commentaires
Jan
Jan le 21 Mai 2017
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 le 21 Mai 2017
Ty Jan, code is now runable, "dongu"---->loops "cubukuzunluk"---->the length of seesaw arms ""dikdegisx""----> tryed something with angles but thats not important

Connectez-vous pour commenter.

Réponse acceptée

MathReallyWorks
MathReallyWorks le 21 Mai 2017
Modifié(e) : MathReallyWorks le 21 Mai 2017
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

Plus de réponses (0)

Catégories

En savoir plus sur Animation dans Help Center et File Exchange

Tags

Aucun tag saisi pour le moment.

Community Treasure Hunt

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

Start Hunting!

Translated by