Real Time Plotting in Gui by taking data from Simulink

16 views (last 30 days)
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?

Answers (1)

Jon
Jon on 16 Sep 2020
One way to do this is using get_param to get data from run time objects
  2 Comments
Jon
Jon on 16 Sep 2020
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 on 7 Nov 2020
I suppose it is fastest real-time plot. Has Simulink linking example.
Well documented. World-wide known.

Sign in to comment.

Categories

Find more on Simulink Functions in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!