小言_互联网的博客

正弦激励下的弦振动方程计算机MATLAB仿真

352人阅读  评论(0)

定解问题:

 仿真思路:求出通解形式,MATLAB可视化处理即可:

代码:

%picture of string vibration
clc;
clear;
% The boundary conditions of string vibration 
% initial condition of string vibration
a=1;
l=1;
A=0.01;
w=6;
x=0:0.05:1;
t=0:0.001:4.3;
%To plot the vibration picture
[X,T]=meshgrid(x,t);
u0=A*sin(w*X./a).*sin(w.*T)/sin(w*l/a);
u=0;
for n=1:100;
    uu=(-1)^(n+1)*sin(n*pi*X/l).*sin(n*pi*a*T/l)/(w*w/a/a-n*n*pi*pi/l/l);
    u=u+uu;
end
u=u0+2*A*w/a/l.*u;
figure(1)
axis([0 1 -0.05 0.05])
h=plot(x,u(1,:),'--','color',[0 0 0],'linewidth',1);
set(h,'erasemode','xor');
for j=2:length(t);
    set(h,'ydata',u(j,:));
    axis([0 1 -0.05 0.05])
    drawnow
end
figure(2)
waterfall(X(1:50:3000,:),T(l:50:3000,:),u(1:50:3000,:))
xlabel('x')
ylabel('t')
    

效果图:


转载:https://blog.csdn.net/qq_41895747/article/details/102216833
查看评论
* 以上用户言论只代表其个人观点,不代表本网站的观点或立场