ode45 is not outputting solutions for each increment specified by my “time-span” vector
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
zek3r
el 21 de Jun. de 2016
Comentada: zek3r
el 23 de Jun. de 2016
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 comentarios
Respuesta aceptada
Mischa Kim
el 22 de Jun. de 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.
Más respuestas (0)
Ver también
Categorías
Más información sobre Ordinary Differential Equations en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!