why the time "t" inside the ode solver OutputFcn is not a scalar?

2 views (last 30 days)
For an ODE problem that I have, I need to evaluate some values right after each successful ODE step. therefore I decided to use OutputFcn (output function that is supposed to run only successful steps). I wrote a code and here is its summay:
options =odeset('OutputFcn',@My_OutputFcn,));
[T,Y]=ode15s(@ode_func,[simulation_time_start,simulation_time_end],initial_conditions,options]
%%%%%%%%%%%%%%%%%
where the OutputFcn is:
function status = My_OutputFcn(t,y,flag,varargin)
global force
t
force= force+t;
%%%%%%%%%%%%%
but the problem is that in the above method, sometimes the parameter t (time) is a vector rather than being a scalar. Why is that happening and how to fix it?
I am printing "t" in the middle of My_OutputFcn and here is a copy of the command window:
t =
0 0.1500
t =
0.0050
t =
0.0100
t =
0.0150
t =
0.0200
t =
0.0250
t =
0.0300
t =
0.0350
t =
0.0400 0.0450
t =
0.0500
t =
0.0550 0.0600
Any help would be greatly appreciated.

Answers (0)

Products

Community Treasure Hunt

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

Start Hunting!