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
> 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.
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