How to create animation ?
조회 수: 1 (최근 30일)
이전 댓글 표시
I have written a code to solve differential equation of a simple pendulum. I tried creating animation of the same. But I am not getting properly. Please correct me.
clear all
close all
clc
%let theeta=y
L=1;
t=[0 20];
yo=[0 3];
[t,y]=ode45('simplependulum',t,yo)
figure(1)
plot(t,y(:,1))
xlabel('time')
ylabel('displacement')
figure(2)
plot(t,y(:,2))
xlabel('time')
ylabel('angular velocity')
O=[0 0];
axis(gca,'equal');
axis([-0.7 0.7 -0.7 0.2]);
grid on;
figure(3)
for i=1:length(t)
P=L*[sin(y(i,1)) -cos(y(i,1))]
O_circle=viscircles(O,0.01);
pend=line([O(1) P(1)],[O(2) P(2)]);
ball=viscircles(P,0.05);
pause(0.001);
if i<length(t)
delete(pend);
delete(ball);
delete(O_circle);
end
end
댓글 수: 0
답변 (1개)
Image Analyst
2018년 12월 22일
See attached demo where I make a movie from different frames of surf() - the surface is changing in time.
댓글 수: 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!