Real Time Plotting in Gui by taking data from Simulink

10 次查看(过去 30 天)
Hi,
I have a real time simulation and i want to make a real time plot in gui. When i take the data from simulink it gives me a finished plot while my simulation is still i running. I want to generate my plot when the action is happening not before. Is there a way to do so?

回答(1 个)

Jon
Jon 2020-9-16
One way to do this is using get_param to get data from run time objects
  2 个评论
Jon
Jon 2020-9-16
First start your simulation running, blocks don't have run time objects until simulation is running
Get the run time objects for the desired blocks using something like:
rto = get_param('myBlockName','RunTimeObject')
note if you don't know the block's name (here I just called it 'myBlockName', you can select the block in the diagram, and then on the command line issue the command
gcb
which will display the block name.
Once you have the run time object assigned to the variable rto, you can get data out of it at any time while the simulation is running using
val = rto.InputPort(1).Data
val = rto.OutputPort(1).Data
to get the instantaneous value of the block input and the output respectively
Michael Bernstein
Michael Bernstein 2020-11-7
I suppose it is fastest real-time plot. Has Simulink linking example.
Well documented. World-wide known.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Simulink Functions 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by