我们知道 1-d 波动方程的解的形式为:$ \begin{aligned} u(x, t) &= \sum_{n=1}^{\infty}\sin(\frac{n\pi x}{L})(A_n\cos(\frac{n\pi ct}{L}) + B_n\sin(\frac{n\pi ct}{L})) \\ &= \sum_{n=1}^{\infty} C_n\sin(\frac{n\pi x}{L})\sin(\frac{n\pi ct}{L} + \theta) \\ &= \sum_{n=1}^{\infty} \frac{C_n}{2}\left [ \cos \left [ \frac{n\pi}{L}(x - ct) - \theta \right ] - \cos \left [ \frac{n\pi}{L}(x + ct) + \theta \right ] \right ]\end{aligned} $
这里仅仅展示 $ n = 3 $ 随时间波动动画,即
clear;clc; pi = 3.1415926; L = 5.; n = 3; T0 = 0.5; pho = 1.; c = sqrt(T0/pho); % u = zeros(100, length(x)); % for i=1:100 % u(i,:) = sqrt(2)*sin(n*pi*x/L)*sin((n*pi*c*(i-1))/L + pi/4.); % end % % t = ones(100, length(x)); % for i=1:100 % t(i,:) = t(i,:)*(i/10.); % end % % f1 = figure; % plot3(t,x,u); f = figure; loops = 100; set(gcf, 'Position', get(0,'Screensize')); for i = 0:loops hold off [x,t] = meshgrid(0:.1:5,i:.03:10+i); z = sqrt(2)*sin(n*pi*x/L).*sin((n*pi*c*t)/L + pi/4.); surf(t,x,z) view(150,70) title('PDE: $$\frac{\partial^2 u}{\partial t^2} = c^2\frac{\partial^2 u}{\partial x^2}, n = 3$$','Interpreter','latex') axis tight manual ax = gca; ax.NextPlot = 'replaceChildren'; axis off drawnow end