How graph second order differential equations with Matlab?

171 vues (au cours des 30 derniers jours)
jake thompson
jake thompson le 18 Jan 2018
Looking to get some help on how to use matlab to solve the following equation problem 6, all help is appreciated! Thank You! I haven't used matlab in 2 years very rusty, image is reference to original problem statement.
4y"-20y'+25y=0
%%PROBLEM 6
clear; syms y(x)
ode = 4*diff(y,x,2) - 20*diff(y,x) + 25*y == 0;
%ySol(x) = dsolve(ode)
%ezplot('ode')
ySol = dsolve(ode, y(0) == 0)
figure
subplot(2,1,1)
ezplot(real(ySol(1)))
subplot(2,1,2)
ezplot(imag(ySol(1)))
ERROR
Warning: Contour not rendered for constant ZData
> In contour (line 52)
In ezplot>ezimplicit (line 315)
In ezplot (line 153)
In sym/ezplot (line 61)

Réponse acceptée

Star Strider
Star Strider le 18 Jan 2018
The problem is that you need to define an initial condition for the first derivative.
Try this:
syms y(x)
Dy = diff(y);
D2y = diff(y,2);
ode = 4*D2y - 20*Dy + 25*y == 0;
ySol = dsolve(ode, y(0) == 0, Dy(0) == 1) % Define The Initial Condition For ‘Dy(0)’ To Be ‘Some Value’
figure
ezplot(ySol)
  3 commentaires
Star Strider
Star Strider le 18 Jan 2018
As always, my pleasure!
Hamid Ghassri
Hamid Ghassri le 8 Juil 2019
Modifié(e) : Hamid Ghassri le 8 Juil 2019
how can you set a range for x

Connectez-vous pour commenter.

Plus de réponses (2)

Phloykan Tepwarin
Phloykan Tepwarin le 18 Jan 2022
yms s t Y u ; u = 10*exp(-t); ic = [0 0]; U = laplace(u, t, s); Y1 = s*Y; Y2 = s*Y1; S = Y2+9*Y-U; Y(s) = solve(S, Y); y = ilaplace(Y(s)); B = simplify(y); pretty(B); h = ezplot(y, [0 10]); set(h,'linewidth',2.5); title('function y(t)'); xlabel('t'); ylabel('y(t)');

Phloykan Tepwarin
Phloykan Tepwarin le 18 Jan 2022
syms s t Y u ;
u = 10*exp(-t);
ic = [0 0];
U = laplace(u, t, s);
Y1 = s*Y; Y2 = s*Y1;
S = Y2+9*Y-U;
Y(s) = solve(S, Y);
y = ilaplace(Y(s));
B = simplify(y);
pretty(B);
h = ezplot(y, [0 10]);
set(h,'linewidth',2.5);
title('function y(t)');
xlabel('t');
ylabel('y(t)');

Community Treasure Hunt

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

Start Hunting!

Translated by