ode45 is not outputting solutions for each increment specified by my “time-span” vector
3 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
Mischa Kim
2016-6-22
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.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Ordinary Differential Equations 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!