% MATLAB commands to generate a movie using data obtained % from the explicit 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 data2; % initialize vector and axes used for plotting wave=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 (nt frames total) for it=1:nt wave(:)=u(:,it); plot(x,wave) axis(lim) drawnow; M(:,it)=getframe; 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,'t=2 (40,100)',[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