📄 test6.m
字号:
% Let's solve Helmholtz's equation
% -div(grad(u))-k^2u=0
% and study the waves reflected from a square object.
% The incoming wave comes from the right
% The incident wave has a wave number of 60.
k=60;
g='scatterg'; % Circle with a square hole
b='scatterb'; % Incident wave Dirichlet conditions on object and
% outgoing wave conditions on outer boundary.
c=1;
a=-k^2;
f=0;
% We need a fairly fine mesh to resolve the waves.
[p,e,t]=initmesh(g);
[p,e,t]=refinemesh(g,p,e,t);
[p,e,t]=refinemesh(g,p,e,t);
% This is the mesh
pdemesh(p,e,t); axis equal
pause % Strike any key to continue.
% Solve for the complex amplitude
u=assempde(b,p,e,t,c,a,f);
% The real part of a phase factor times u gives the instantaneous
% wave field. This is at phase 0.
%
% Use Z buffer to speed up the plotting.
h = newplot; set(get(h,'Parent'),'Renderer','zbuffer')
pdeplot(p,e,t,'xydata',real(u),'zdata',real(u),'mesh','off');
colormap(cool)
pause % Strike any key to continue.
h=newplot; hf=get(h,'Parent'); set(hf,'Renderer','zbuffer')
axis tight, set(gca,'DataAspectRatio',[1 1 1]); axis off
M=moviein(10,hf);
maxu=max(abs(u));
colormap(cool)
for j=1:10,
ur=real(exp(-j*2*pi/10*sqrt(-1))*u);
pdeplot(p,e,t,'xydata',ur,'colorbar','off','mesh','off');
caxis([ -maxu maxu]);
axis tight, set(gca,'DataAspectRatio',[1 1 1]); axis off
M(:,j)=getframe(hf);
end
movie(hf,M,50);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -