I've the following code to obtain [t,x] after simulating odes . In addition to the solution, I also want to obtain the functiion values F(x,t) in the below equation.
x0 = initial values;
tspan = 0:0.0001:0.5;
options = odeset('abstol', 1e-10, 'reltol', 1e-9);
[t, x] = ode15s(@(t,x) fun(t,x), tspan , x0 ,options);
[dy f] = fun([ ], [ ])
function [dy f] = fun(t,x)
f = 
dy = A*x
if nargout >1
f = horzcat(f, A*x)
In the code, I've defined a persistent variable, f, that stores F for each time step that I solver takes. And I receive f using `[dy f] = fun([ ], [ ])``
But the size of f and x are not equl because from what I understand the output of x is given (after interpolation I guess) only at the time points defined in tspan. Whereas, f is saved for very time instant t that the solver takes internally.
In summary my question is, how do I obtain f for the same time instants at which x is obtained.