As a beginner in Matlab I am exploring the ode45 function with test.m containing the ode equation to be solved.
In an editor I call this function separatey via 2 options. In one case I have the defined Option 1
t=[0 50];
y0=[0 2];
[t,y]=ode45(@(t,y)test(t,y),t,y0);
and in option 2 I ask for a structure output
t=[0 50];
y0=[0 2];
sol=ode45(@(t,y)test(t,y),t,y0);
However, the resulting time steps are less for the structure option 2 compared to option 1 and so my plots are "coarser".
I could not find a way to increase the number of steps to refine the solution for option 2....Any ideas?
Use the deval
function with sol
and your chosen time points. For example,
tSpan = 0:0.01:50;
y = deval(sol, tSpan);
plot(tSpan,y)
See Evaluate and Extend Solution Structure in the documentation