How graph the function and solution of a second order differential equation with Matlab in the same graph.

1 次查看(过去 30 天)
How can I plot the the function and the solution in the same graph?
t=dsolve('D2x+4*Dx+4*x=t^2+exp(-2*t)','Dx(0)=1','x(0)=.5');
pretty(simplify(xt))
2 2
exp(-2 t) t t exp(-2 t) 7 t exp(-2 t) t 3
--------- - - + ------------- + ------------ + -- + -
8 2 4 2 4 8
ezplot(xt),;hold on
ezplot('D2x+4*Dx+4*x=t^2+exp(-2*t)'),
Error using ezplot
D2x+4*Dx+4*x=t^2+exp(-2*t) cannot be plotted in the xy-plane.

回答(1 个)

Eustace Tan
Eustace Tan 2019-7-25
Plot the right hand side of the equation.

类别

Help CenterFile Exchange 中查找有关 2-D and 3-D Plots 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by