From: William on
Hi, I've created a script that will preform a simple calculation for me, and then plot it. I would like to somehow make these plots into animations and then plot variations of the initial conditions (Such that the angle,velocity or maybe position would change). I believe to do this I would use a For loop, but i cannot figure out how to begin. Any help is apperciated.


% angle = Angle of trajectory
% V = Velocity
% p = Position from x-axis.
%
% Inputs

angle = input('Enter angle of trajectory (degrees)= '); %Angle
V= input('Enter velocity= '); %Velocity
p= input('Enter Position of elevation= '); %Position
G= 9.8; %Gravity
t=0:.01:50; %# of Calculations

% math/graphics

f= t*V*cosd(angle); %Flight "X component"
h1= p+t*V*sind(angle) - 1/2*G*t.^2; %Height1 "Y component"
pause(0.1); plot(f,h1,'-'); hold on; %Plot
set(gca,'ylim',[0,max(h1)+(max(h1)/6)]) %Graphical restrictions
xlabel('Distance (m)'); ylabel('Height (m)'); %Labels
heightmax = max(h1)
ix=find(h1<0,1,'first');
From: Andy on
To get started:

doc getframe
doc movie
From: Matt Fig on
Also, see COMET and the 'nextplot' property of axes objects as two ways of avoiding having to make movies.