Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

current step size in simulink

1,318 views
Skip to first unread message

George

unread,
Nov 3, 2008, 4:44:02 PM11/3/08
to
Hi, I have two questions:

1) is there any way to access the current step size of a simulation done in Simulink when a variable-step integrator is used? I would like to use this inside an m function and not for debugging purposes, i.e. I cannot use something like strace.

2) is there any flag that changes value when simulink moves between the different stages of the loop iteration when variable-step integrators are used? In particular, can I find out whether Simulink computes the model outputs or tries to determine the next step-size?

Thanks

Phil Goddard

unread,
Nov 3, 2008, 10:24:03 PM11/3/08
to
George,

> 1) is there any way to access the current step size of a simulation done in Simulink when a variable-step integrator is used? I would like to use this inside an m function and not for debugging purposes, i.e. I cannot use something like strace.

Feeding the clock block into a memory block then taking the difference will tell you what the step size currently being evaluated is.
This could then be fed into your function as an input.

Of course that does you no good if you need to know the step size before any blocks get updated.

> 2) is there any flag that changes value when simulink moves between the different stages of the loop iteration when variable-step integrators are used? In particular, can I find out whether Simulink computes the model outputs or tries to determine the next step-size?

If you write an m-code S-Function rather than a straight MATLAB function (called from the MATLAB Function block) then yes, Simulink passes the block information on what it is currently doing (i.e. updating states, updating outputs, determining the next sample time).

However, that information is done on a block by block basis.
I don't believe there's a way to determine this information on a model wide basis.

Phil.

Riccardo

unread,
Nov 5, 2008, 7:44:02 AM11/5/08
to
"George " <gfai2000.at.ne...@netscape.net> wrote in message <genrb2$mm1$1...@fred.mathworks.com>...

Phil,
you'll need an s-function - preferably a c-mex one - if you want to get hold of information related to the step-size management.
Check the simstruct content for the version you're running - see simstruct.h in <matlabroot>\simulink\include to get an idea of the whereabouts of parameters of interest.
Then the best way to familiarize yourself with the way the simulation works is to compile the s-function with extended debug info and run it, setp by step, in a debugger session.
HTH
Riccardo

varun dj

unread,
Oct 29, 2009, 3:46:01 AM10/29/09
to
Hi
Is it possible to get the step size of a model in code (S-Function)?

Sameer

unread,
Jun 18, 2014, 10:27:09 AM6/18/14
to
"varun dj" wrote in message <hcbh7p$fas$1...@fred.mathworks.com>...
> Hi
> Is it possible to get the step size of a model in code (S-Function)?

Hi....Did you got any way to determine the stepsize of a model. If so then please guide.....

Regards

filipj89

unread,
Jun 2, 2016, 10:36:09 AM6/2/16
to
"Sameer" wrote in message <lns7jt$dij$1...@newscl01ah.mathworks.com>...
Hi I am not sure, but is this what are you looking for time_T dt = ssGetFixedStepSize(S)
0 new messages