|
以下取之《数学物理方程的MATLAB解法与可视化实现》一弦两端固定时驻波的振动动态模式的程序,可见采用MATLAB编程求解方程完全可得振动的动态模式。
clear all; clc;
t=0:0.005:2.0; x=0:0.001:1;
ww1=wfun(1, 0); ww2=wfun(2,0);
ww3=wfun(3, 0); ww4=wfun(4,0);
ymax1=max(abs(ww1));
figure
subplot(2,1,1 )
h1=plot(x,ww1,'r', 'linewidth' ,5);
hold on;
h3=plot(x, ww3, 'g', 'linewidth' ,5);
axis([ 0, 1, -ymax1, ymax1])
subplot (2,1,2)
ymax4=max(abs(ww4));
h2=plot(x,ww2,'r', 'linewidth' ,5);
hold on;
h4=plot(x,ww4, 'g', 'linewidth' ,5);
axis([ 0, 1, -ymax4, ymax4])
for n=2:length(t)
ww1=wfun( 1, t(n));
set(h1, 'ydata' ,ww1);
ww3=wfun(3, t(n));
set(h3, 'ydata',ww3);
drawnow;
ww2=wfun( 2, t(n));
set(h2, 'ydata',ww2);
ww4=wfun(4, t(n));
set(h4, 'ydata',ww4);
drawnow;
end
function wtx=wfun(k, t)
x=0:0.001:1; a=1;
wtx=cos(k*pi*a*t).*sin(k*pi*x);
[ 本帖最后由 songzy41 于 2006-8-19 15:39 编辑 ] |
评分
-
1
查看全部评分
-
|