% MATLAB commands to generate a movie using data obtained from % the explicit (wave.f) method for the wave equation (wave.f)... clear; % read in the values for nx, nt, u(nx,nt), and x(nx) % see data file data.m for details about format data184; data368; % initialize vectors and axes used for plotting wave1=zeros(nx,1); wave2=zeros(nx,1); axis([0 1.0 -1.0 1.0]) set(gca,'Position',[0.13 0.11 0.4 0.5]) lim=axis; M=moviein(nt); % loop to produce frames of the movie for it=1:nt wave1(:)=u(:,it); wave2(:)=u2(:,it); plot(x,wave1,'b-') hold on plot(x,wave2,'r-') axis(lim) drawnow; M(:,it)=getframe; hold off end; % various commands to show movie movie(M); movie(M,3); % the following are used to compare the first and last frame q1=zeros(nx,1); q2=zeros(nx,1); q1(:)=u(:,1); q2=u(:,nt); plot(x,q1,x,q2); % create Quicktime file containing movie % this command only works on a Mac map=colormap; qtwrite(M,map,'nt=186 nt=386',[12,3,3]); % you can also make a MPEG file using the mpgwrite command % the m-file for this command can be found at % http://www.mathworks.com/ftp/graphicsv5.shtml