matlab - How I can create a movie from a bunch of plots -
i beginner make movie. need make movie bunch of plots. how can make it. have 8 plots , y versus x. want make movie based on x see how y change increasing x.
please consider matlab file below:
x=[1 1.2 1.4 2 3 4 5 7 9 10]; y1=[2.8 7.6 10.9 12.3 15.0 21 12.3 14.5 42.4 47.7]; y2=1e8.*[0.599e-7 0.607e-7 0.343e-7 0.3e-7 0.873e-8 0.578e-8 0.298e-8 0.725e-9 0.14e-8 0.478e-9]; y3=10.*[0.136 0.544 0.834 1.03 0.366 0.314 0.703 0.207 0.696 0.164]; y4=10.*[0.26 0.21 0.17 0.25 0.31 0.34 0.16 0.15 0.13 0.31]; y5=.... y6=... y7=... y8=[6 7.6 10.9 12.3 15.0 21 12.3 19.5 42.4 47.7 ]; plot(x,y1) hold on plot(x,y2) hold on plot(x,y3) hold on plot(x,y4) hold on plot(x,y5) hold on plot(x,y6) hold on ... plot(x,y8)
i wrote following simple example not work:
clc;clear all; x=[1 1.2 1.4 2 3 4 5 7 9 10]; y = zeros(4,10); y(1,:)=[2.8 7.6 10.9 12.3 15.0 21 12.3 14.5 42.4 47.7 ]; y(2,:)=1e8.*[0.599e-7 0.607e-7 0.343e-7 0.3e-7 0.873e-8 0.578e-8 0.298e-8 0.725e-9 0.14e-8 0.478e-9]; y(3,:)=10.*[0.136 0.544 0.834 1.03 0.366 0.314 0.703 0.207 0.696 0.164 ]; y(4,:)=10.*[0.26 0.21 0.17 0.25 0.31 0.34 0.16 0.15 0.13 0.31 ]; figure; hold on n = 1:10 plot(x,y) m(n)=getframe; % frame current figure; end movie(m,10); %plays movie m 10 times
in nut shell , how can make movie fig. 3.2: in following link
the basic code making movie given figure this:
figure; hold on n = 1:20 plot(1:10,n*(1:10)) m(n)=getframe; % frame current figure; end movie(m,10); %plays movie m 10 times
look files getframe
, movie
see other options available. save movie out, see movie2avi
.
note given figure need call hold on
once. if y
values of same length, can re-write code/plotting more efficiently this:
x=[1 1.2 1.4 2 3 4 5 7 9 10]; y = zeros(8,10); % each of sets of y values y(1,:) = [2.8 7.6 10.9 12.3 15.0 21 12.3 14.5 42.4 47.7 53 81.3 86.1]; ... y(8,:)=[6 7.6 10.9 12.3 15.0 21 12.3 19.5 42.4 47.7 53 81.3 86.1 ]; plot(x,y) % plots y's against x automatic coloring plot(x,y(n,:)) % plots 1 set of y values against x
Comments
Post a Comment