ode45 is not outputting solutions for each increment specified by my “time-span” vector
3 views (last 30 days)
Show older comments
I am using the following code to call a function for ODE45 to solve:
[outputs]=ode45(@(t,y)ILLYAcoupled(t,y,N,w,g),(0:0.5e-3:50),y0);
I am trying to get ode45 to give me values at 0.5e-3 increments between 0 and 50, which should output a solution vector length of about 10000, but I'm getting a solution vector of only 2720 points. What is weird is that I was calling another function for ode45 to solve in the following fashion:
[outputs] = ode45(@HH,(0:0.5e-3:50),y0);
...and this was giving me the desired 10000 length solution vector--until recently. I tried calling it in this way:
[outputs] = ode45(@(t,y)HH(t,y),(0:0.5e-3:50),y0);
...which gave me a 2720 length solution vector and, now, even when I've changed the code back to the "@HH" by itself it keeps giving me the 2720 length vector rather than the desired 10000 length one.
It seems like something in the way I am specifying inputs and outputs to the called function during the ode45 call is messing things up but I don't know what.
I will be super grateful for any advice one might have!! Thanks!
0 Comments
Accepted Answer
Mischa Kim
on 22 Jun 2016
zek3r, use
[tsol,ysol] % returns vectors/matrices
instead of
[outputs] % returns structure
as the output arguments. Alternatively, if you want or need to keep working with the outputs structure you can use deval to evaluate the solution at any point in the time interval. See the documentation for more info.
More Answers (0)
See Also
Categories
Find more on Ordinary Differential Equations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!