필터 지우기
필터 지우기

Plotting Animation Help Needed

조회 수: 2 (최근 30일)
ByPhoenix
ByPhoenix 2017년 5월 20일
편집: MathReallyWorks 2017년 5월 21일
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