Problem with Ode Solver
Mostrar comentarios más antiguos
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?
Respuestas (1)
Torsten
el 20 de Feb. de 2015
1. The vector of Initial values is [12 21].
2. The plot command must read
plot (t,x(:,1));
Best wishes
Torsten.
Categorías
Más información sobre Ordinary Differential Equations en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!