How to solve this differential equation

2 vues (au cours des 30 derniers jours)
Mat
Mat le 23 Jan 2011
Hello,
Im pretty new to using Matlab, and I'm sort of confused on how to solve this equation in Matlab.
y'' + y = x^2
I have the symbolic tool box required, but I'm not sure if matlab can solve this equation. I also don't know the syntax properly on how I would ask Matlab to do this question.
  2 commentaires
John D'Errico
John D'Errico le 23 Jan 2011
Are you looking for a symbolic or numerical solution? How would you turn this into a system of two first order differential equations? (hint: Differential Equations 101)
Paulo Silva
Paulo Silva le 23 Jan 2011
Here's two video tutorials for you Mat
http://www.youtube.com/watch?v=5qH4bmHR1YM
http://www.youtube.com/watch?v=fx3bl4oA_0U
They are very simple :)

Connectez-vous pour commenter.

Réponses (2)

Walter Roberson
Walter Roberson le 23 Jan 2011
You might have to use a slightly different call for MuPad. In Maple it would look like,
dsolve(diff(y(t), t, t)+y(t) = x^2)
and the answer would be:
y(t) = sin(t)*_C2+cos(t)*_C1+x^2
  1 commentaire
Christopher Creutzig
Christopher Creutzig le 24 Jan 2011
I guess Mat meant to use y(x), though.

Connectez-vous pour commenter.


Christopher Creutzig
Christopher Creutzig le 24 Jan 2011
MATLAB:
>> dsolve('D2y + y = x^2', 'x')
ans =
C10*cos(x) + C11*sin(x) + x^2 - 2
 
MuPAD:
solve(ode({y''(x) + y(x) = x^2}, y(x)))
2
{C2 cos(x) + C3 sin(x) + x - 2}

Community Treasure Hunt

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

Start Hunting!

Translated by