Changing Marker Types in a Plot for a Movie - Also General Movie Troubleshooting?
1 view (last 30 days)
Hello! I'm taking a one-credit MATLAB class at university, and I could really use the community's help for my current assignment.
The primary objective of this assignment is to create a movie from the given file, and learning how to use the "movie" and "getframe" commands. That's all fine and dandy. I think I've done that much, although when it's run, the movie's first run is always very slow. Then, the second run of the movie is much faster. Also, if I click any other figure windows, the movie will appear and start playing on that figure window, too.
The secondary objective is to change the marker type for each segment of the rocket's launch in the movie. For example, a diamond marker on the plot during segment 1, when the rocket engine is on; a cross marker for segment 2, when the engine is stopped and the parachute is still closed; and a circle marker for segment 3, when the parachute opens. It can be any marker type, but it needs to change depending on what segment is being plotted.
clear all; clc;
%This program models the flight of a small rocket
m=0.05; g=9.81; tEngine=0.15; Force=16; vChute=-20; Dt=.01;
clear t v h
t(n)=0; v(n)=0; h(n)=0;
%Segment 1: The rocket engine is on during the first .15 seconds
while t(n)<tEngine && n<50000
v1=v(n); h1=h(n); t1=t(n);
%Segment 2: The rocket engine has stopped but the parachute hasn't opened
while v(n)>= vChute && n<50000
v2=v(n); h2=h(n); t2=t(n);
%Segment 3: The parachute opens and the rocket floats to the ground
while h(n)>0 && n<50000
%% Position-Time Graph Movie
fig2 = figure(2);
for i = 1:n
axis ([0 12 1 120])
M(i) = getframe(fig2);
%% Velocity-Time Graph Movie
fig3 = figure(3);
for i = 1:n
axis ([0 12 -30 50])
M2(i) = getframe(fig3);
The %%Movie sections are what I coded, everything above it was a part of the given file.
Any ideas? I tried putting each segment's "while" statements inside the "for" loops, but the figure would open and the movie would never start.
Thanks so much!