Problem with Ode Solver
Mostra commenti meno recenti
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?
Risposte (1)
Torsten
il 20 Feb 2015
1. The vector of Initial values is [12 21].
2. The plot command must read
plot (t,x(:,1));
Best wishes
Torsten.
Categorie
Scopri di più su Ordinary Differential Equations in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!