有一個波Psi=cos(0.5*beta*x/w_mn+w_mn*t)*sin(m*pi*x/L_x)*sin(n*pi*y/L_y)
這時候想畫出Psi隨時間的變化,並保存成GIF格式
MATLAB代碼:
function []=CalPsi()
Omega=2*pi/(24*60*60);
theta0=90/180*pi;
f0=2*Omega*sin(theta0);
g=9.8;
H0=4000;
c0=sqrt(g*H0);
a=6370*1000;
beta=2*Omega*cos(theta0)/a;
LD=c0/f0;
%assumption Lx=Ly=LD
m=3;
n=3;
xmax=3*10^6;
x=0:xmax/100:xmax;
y=0:xmax/100:xmax;
[X,Y]=meshgrid(x,y);
i=0;
%for t=0:5*10^20:10^22%mn=11
%for t=0:5*10^21:10^23%mn=31
%for t=0:10^21:2*10^22%mn=13
for t=0:10^21:2*10^22%mn=33
figure();
mesh(X,Y,cos((-(4*m^2+n^2)*pi*pi+1)*X/(4*m*pi*LD)-2*m*pi*beta*LD*t/((4*m*m+n*n)*pi*pi+1)).*sin(m*pi*X/LD).*sin(n*pi*Y/LD));
title(sprintf('m=%d\nn=%d\ntime = %f s',m,n,t));
i=i+1;
print(1,sprintf('112233/%d',i),'-dbmp')
close;
end
for j=1:i
im=imread(sprintf('112233/%d.bmp',j));
[I,map]=rgb2ind(im,20);
if j==1
imwrite(I,map,'112233/GIF/meow5.gif','gif', 'Loopcount',inf,'DelayTime',0.2);%FIRST
else
imwrite(I,map,'112233/GIF/meow5.gif','gif','WriteMode','append','DelayTime',0.2);
end
end
close all;
end
就這樣吧,也沒有甚麼需要解釋的。當作筆記方便以後查看喵>_<