Thread Subject: current step size in simulink

Subject: current step size in simulink

From: George

Date: 3 Nov, 2008 21:44:02

Message: 1 of 4

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
 

Subject: current step size in simulink

From: Phil Goddard

Date: 4 Nov, 2008 03:24:03

Message: 2 of 4

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.

Subject: current step size in simulink

From: riccardo

Date: 5 Nov, 2008 12:44:02

Message: 3 of 4

"George " <gfai2000.at.netscape.dot.net@netscape.net> wrote in message <genrb2$mm1$1@fred.mathworks.com>...
> 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,
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

Subject: current step size in simulink

From: varun dj

Date: 29 Oct, 2009 07:46:01

Message: 4 of 4

Hi
Is it possible to get the step size of a model in code (S-Function)?

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Tag Activity for This Thread
Tag Applied By Date/Time
simulink George 3 Nov, 2008 16:45:06
integration ste... George 3 Nov, 2008 16:45:06
rssFeed for this Thread

Contact us at files@mathworks.com