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

1 次查看(过去 30 天)
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.

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Ordinary Differential Equations 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by