After using ode45
to solve a set of ODEs, I want to write a Matlab function to take the initial conditions x_0 as inputs and gives the final state x_1 at time T as the output, thus creating a discrete dynamical system f.
However, I'm having some trouble writing the function that would embed the initial conditions, the ode45
solver, and the final state as the output.
My attempt:
% F is the function handle to the set of ODEs to be solved
x_0 = some initial conditions here
T = 10
function x_1 = f(x_0);
[t, y] = ode45( F, [0 T], x_0 );
% store final state values in variables
x_final = y( end, 4 );
y_final = y( end, 5 );
theta_final = y( end, 3 );
% now define the output of f to take the above final state values
x_1 = [ x_final y_final theta_final ];
end
This doesn't seem to work. I get the messages:
(1) The function 'f' might be unused
(2) The value assigned here to 't' appears to be unused. Consider replacing it with ~.
What am I missing?
Thanks,