📄 p5_14.m
字号:
% P5_14.M Solve the equation D2y-4*Dy+3*y = f(x)% for f(x)=0 and f(x)=10*exp(-2x)% (Requires Symbolic Math Toolbox)% Uses gtext command to annotate curves%y1=dsolve('D2y-4*Dy+3*y=0','y(0)=1','Dy(0)=-3','x')%tf=1.0clfhold onezplot(y1,[0,tf]); gtext('f(x)=0')pausey2=dsolve('D2y-4*Dy+3*y=10*exp(-2*x)','y(0)=1','Dy(0)=-3','x')ezplot(y2,[0,tf])gtext('f(x)=10*exp(-2x)')title('Solution to D2y-4*Dy+3*y=f(x)')ylabel('y(t)')zoomhold off%% Comment%% Comparing the analytic solution with dsolve and the numerical% solution using 0de23 shows that the error in the numerical% result increases rapidly for x > 8.% %% Version 5 change call to ezplot [0,1]
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -