% MATLAB commands used to generate square wave movie tmax=45; nt=200; nx=200; % initialize vector and axes used for plotting dt=tmax/(nt-1); x=linspace(-10,10,nx); y=zeros(1,nx); for ix=1:nx y(ix)=f(x(ix)); end; plot(x,y) axis([-10 10 -1.5 1.5]); lim=axis; set(gca,'Position',[0.13 0.11 0.5 0.6]); M=moviein(nt); % loop to produce frames of the movie (nt frames total) for it=1:nt t=dt*(it-1); for ix=1:nx s=x(ix)-t; r=x(ix)+t; F=f(s)-f(s+20)+f(s+40); G=f(r)-f(r-20)+f(r-40); y(ix)=0.5*(F+G); end; plot(x,y) axis(lim) drawnow; M(:,it)=getframe; end; % create Quicktime file containing movie map=colormap; qtwrite(M,map,'square wave movie',[12,3,3]); % m-file used to define IC function function z=f(s) if s>1 z=0; elseif s<-1 z=0; else z=1; end;