Info
This question is closed. Reopen it to edit or answer.
Problem with ode solvers
1 view (last 30 days)
Show older comments
I'm trying to use ode45 to solve a system of ODE, but it returns my initial conditions, what I did wrong?
function dy = camila(t,y)
dy = zeros(4,1); dy(1) = -0.5*dy(4)-0.5*dy(3)-0.5*y(4); dy(2) = -0.5*dy(4); dy(3) = 0.5*dy(1); dy(4) =5*((5/(5+2))*(1-((y(2)/y(1))/3)^2))*y(4);
[T, XY] ode45('camila',0,10,[36.128 0.505 0.54 0])
T =
0
0.2500
0.5000
0.7500
1.0000
1.2500
1.5000
1.7500
2.0000
2.2500
2.5000
2.7500
3.0000
3.2500
3.5000
3.7500
4.0000
4.2500
4.5000
4.7500
5.0000
5.2500
5.5000
5.7500
6.0000
6.2500
6.5000
6.7500
7.0000
7.2500
7.5000
7.7500
8.0000
8.2500
8.5000
8.7500
9.0000
9.2500
9.5000
9.7500
10.0000
DY =
36.1280 0.5050 0.5400 0
36.1280 0.5050 0.5400 0
36.1280 0.5050 0.5400 0
36.1280 0.5050 0.5400 0
36.1280 0.5050 0.5400 0
36.1280 0.5050 0.5400 0
36.1280 0.5050 0.5400 0
36.1280 0.5050 0.5400 0
36.1280 0.5050 0.5400 0
36.1280 0.5050 0.5400 0
36.1280 0.5050 0.5400 0
36.1280 0.5050 0.5400 0
36.1280 0.5050 0.5400 0
36.1280 0.5050 0.5400 0
36.1280 0.5050 0.5400 0
36.1280 0.5050 0.5400 0
36.1280 0.5050 0.5400 0
36.1280 0.5050 0.5400 0
36.1280 0.5050 0.5400 0
36.1280 0.5050 0.5400 0
36.1280 0.5050 0.5400 0
36.1280 0.5050 0.5400 0
36.1280 0.5050 0.5400 0
36.1280 0.5050 0.5400 0
36.1280 0.5050 0.5400 0
36.1280 0.5050 0.5400 0
36.1280 0.5050 0.5400 0
36.1280 0.5050 0.5400 0
36.1280 0.5050 0.5400 0
36.1280 0.5050 0.5400 0
36.1280 0.5050 0.5400 0
36.1280 0.5050 0.5400 0
36.1280 0.5050 0.5400 0
36.1280 0.5050 0.5400 0
36.1280 0.5050 0.5400 0
36.1280 0.5050 0.5400 0
36.1280 0.5050 0.5400 0
36.1280 0.5050 0.5400 0
36.1280 0.5050 0.5400 0
36.1280 0.5050 0.5400 0
36.1280 0.5050 0.5400 0
0 Comments
Answers (1)
Star Strider
on 3 Mar 2014
Edited: Star Strider
on 3 Mar 2014
You have a minor problem with the way you specify the integration time interval.
From the documentation (with added emphasis):
[T,Y] = solver(odefun,tspan,y0)
‘ tspan --- A vector specifying the interval of integration, [t0,tf]. ’
I did not run your code, but if you change your call to ode45 to:
[T, XY] ode45('camila',[0,10],[36.128 0.505 0.54 0])
It should work as you want it to if you did everything else correctly.
2 Comments
Star Strider
on 3 Mar 2014
Edited: Star Strider
on 3 Mar 2014
Something is wrong with your differential equation. You are mixing ‘y’ and ‘dy’, and the ode solvers want one or the other on the right side of the equations.
What are the original equations you want to integrate?
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!