Here is the function I am trying to solve along with the domain and initial condition:
tspan=[0 10];x0=0;func=@(t,x) -2*x+t;
If I try to solve the ode with the following format, the vectors are of size 57×1:
[t,x] = ode45(func, tspan, x0);
However, if I try to solve the ode with another format, the vectors are of size 1×15:
sol = ode45(func, tspan, x0);t=sol.x;x=sol.y;
The reason I want to know this is because I want the length and number of time steps during the integration. If I had to guess, I would say that it is given with the second format because if I write it like this:
options = odeset('Stats','on');[t,x] = ode45(func, tspan, x0, options);
the following appears in the command window :
14 successful steps
2 failed attempts
97 function evaluations
This tells me that there are 14 time steps so the size of sol.t is the correct one. Am I missing something?
Best Answer