solving ordinary differential equations
12 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
abdallah alwohoush
am 31 Dez. 2021
Bearbeitet: Torsten
am 31 Dez. 2021
Hello, I'm a beginner in matlab. I'm trying to solve ODE in matlab, but I'm getting error I don't know why!
This is the equation d2y(t) / dt2 + 2 dy/dt + 5 y(t) = 5 cos1500t, I attached a photo of my code with the errors.

1 Kommentar
Akzeptierte Antwort
Cris LaPierre
am 31 Dez. 2021
I think the reason for the error is that you have defined dy as a sym variable rather than a symfun, so it is interpretting the '(0)' to be an index into variable dy rather than dy at t==0.
Try this
syms y(t)
dy(t) = diff(y(t),t)
dy2(t) = diff(y(t),t,2)
equation = dy2 + 2*dy + 5*y(t) == 5*cos(1500*t)
i1 = y(0) == 0;
i2 = dy(0) == 0;
dsolve(equation,[i1,i2])
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Symbolic Math Toolbox finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!