%To animate acoustic modes in rooms
clear all;
clc;
close all;
Nsteps=30;
f=4380; % Frequency does not matter here
w=2*pi*f;
t=linspace(2*pi/Nsteps/w,2*pi/w,Nsteps);
c=344;
rho=1.15;
rhoc=rho*c;
k=w/c;
nx=1;
ny=2;
x=linspace(.01,1,100);
y=linspace(.01,1,100);
  for m=1:100
   for l=1:100
         p1=cos(nx*pi*x(l));
         p2=cos(ny*pi*y(m));
         pt(l,m)=p1*p2;
    end
 end
 
pmag=abs(pt);
clim=max(max(pmag));
V=[-clim clim];							

figure(1)
pt2=real(pt);
H=pcolor(x,y,pt2);
axis equal
axis([0 1 0 1])

%M=moviein(Nsteps); 

for kk=1:Nsteps
   pt2=real(pt*exp(i*w*t(kk)));
   h=pcolor(x,y,pt2);
   axis equal
	xlabel('x');
   ylabel('y');
   title('Pressure')
   shading interp;
   caxis(V);
   axis([0 1 0 1])
   
%   M(:,kk)=getframe;
% to store the images for web posting (bitmaps)
filnme=strcat('spher',int2str(kk));
eval(['print -dbitmap ' filnme ' -f']);
end

%movie(M,20)