📄 e953.m
字号:
%-------------------------------------------------------------------
% Example 9.5.3: Vibrating String
%-------------------------------------------------------------------
% Initialize
clc
clear
global c1 c2
c1 = 0.1;
c2 = 0.1;
a = 2; % string length
m = 80; % t precision
n = 39; % x precision
T = 1.0; % maximum t
beta = 4.0; % gain
E = 0; % error
% Find gamma
fprintf ('Example 9.5.3: Vibrating String\n');
dt = T/m;
dx = a/(n+1);
gamma = beta*dt*dt/(dx*dx);
show ('gamma',gamma);
% Solve wave equation
disp ('Solving wave equation ...');
[t,x,U] = wave1 (T,a,m,n,beta,'funf953','fung953');
plotxyz (t,x,U,'Vibrating String','t','x','u');
% Check the accuracy
for i = 1 : m+1
for j = 1 : n
w(i,j) = funv953(t(i),x(j));
E = max([E,abs(U(i,j)-w(i,j))]);
end
end
show ('maximum error',E);
%-------------------------------------------------------------------
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -