Problem with Ode Solver
Afficher commentaires plus anciens
The differential equation is y''+ 5y'+7y=0, with y(0)=12 and y'(0)=21. Accordingly, I created a matlab function
function dxdt=odeprac(t,x)
dxdt =[x(2); -7*x(1)-5*x(2)];
Here, y=x(1) and y'=x(2) If I run the command
[t,x] = ode45(@odeprac,tspan,[21; 12]);
>> plot(t,x(1));
Then I do not get the time path of y (which, ideally, should show waves), but a horizontal line at x1=21. Even rescaling the axes or trying other ode solver do not help.
What other options I may try?
Réponses (1)
Torsten
le 20 Fév 2015
1. The vector of Initial values is [12 21].
2. The plot command must read
plot (t,x(:,1));
Best wishes
Torsten.
Catégories
En savoir plus sur Ordinary Differential Equations dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!