Is ode45 always calculate the entire function even if she has been asked only for specific values?

1 view (last 30 days)
t0=0;
tf=5;
r=5;
s=1;
AnonFun=@(t,x)(r*x-s*x^2);
[t,x]=ode45(AnonFun,[t0,tf],1);
plot(t,x)
For example , if i write [t,x]=ode45(AnonFun,0:3,1);
does ode45 calculate the entire function ? or only this 3 points ?
I mean, will it do the full calculation in the background and return only 3 points?

Accepted Answer

Torsten
Torsten on 14 Aug 2022
I mean, will it do the full calculation in the background and return only 3 points?
Yes, it will do the full calculation in the background. The array "tspan" is only set for output purposes - it doesn't influence the computations.
By the way: You specified four output points, not three (0,1,2,3).

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!