MATLAB Answers

Real Time Plotting in Gui by taking data from Simulink

4 views (last 30 days)
Baris Bilen
Baris Bilen on 16 Sep 2020
Commented: Jon on 16 Sep 2020
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?


Sign in to comment.

Answers (1)

Jon on 16 Sep 2020
One way to do this is using get_param to get data from run time objects

  1 Comment

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

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!