Discussion:
Getting Simulink block output from matlab command line
(too old to reply)
Irsan Halim
2008-07-07 23:07:01 UTC
Permalink
Hi,

Is it possible to get the output value of a Simulink model
using the Matlab command line?
We want to be able to read the output value while the
simulation is still running (i.e. we set the stop time to
'inf'). We suspect that we need use the 'get_param' command,
but we're not sure what the full command is. Some examples
will be helpful.
Thanks.
Devdatt Lad
2008-07-08 13:17:27 UTC
Permalink
Post by Irsan Halim
Is it possible to get the output value of a Simulink model
using the Matlab command line?
We want to be able to read the output value while the
simulation is still running (i.e. we set the stop time to
'inf'). We suspect that we need use the 'get_param' command,
but we're not sure what the full command is. Some examples
will be helpful.
You will not be able to use GET_PARAM for this. As the name suggests, this
function can only be used to get parameter values, and not outputs or other
signal values.

The cleanest way to do this is to use a To Workspace block. However, you
will not be able to access the stored data until the simulation is over. And
if the stop time is set to Inf ... well then, you probably don't want to
wait that long.

In that case, an alternative method is available using the Simulink
Execution Event Listener API.

doc add_exec_event_listener

Using this function, register a "PostOutputs" event listener for the
particular block of interest and assign an M-file as the callback function.
Thus, after each outputs method on this block, your M-file will be called by
Simulink. The doc page points to an API you can use to access the output of
that block. (Check out the doc section titled "Accessing Block Data During
Simulation".)

Hope this helps.
--
Devdatt Lad
The MathWorks, Inc.
Loading...