How to plot a Simulink Desktop Real-Time model output in an App Designer app?

39 visualizzazioni (ultimi 30 giorni)
I need to create an app that runs a Simulink Desktop Real-Time model and plots the output in the app. The model has a Analog Input block connected to a scope. For having the signal output to the workspace, I configured the scope properties --> logging and checked 'log data to workspace'.
In the app, I am having an UIAxes for plotting the simulation output.
Eventhough I am capable of running the model using 'set_param' command, I am unable to plot the output in the UIAxes.
Any information will be helpful and thanks in advance.

Risposta accettata

Ankit il 14 Giu 2021
Hi Nagendra,
There are different ways to acheive and one solution you can find in the below link:
let me know if you are looking for this
  4 Commenti
Ankit il 30 Giu 2021
function varargout = plotApp(varargin)
persistent plotting
hf = findall(0, '-property','tag' );
ht = get(hf, 'tag');
[a,b] = ismember('plotAxes',ht);
if a
plotting = hf(b);
rto1 = get_param( 'AppDesignSetup/Scope','RuntimeObject');
Y1 = rto1.InputPort(1).Data;
X1 = get_param('AppDesignSetup','SimulationTime');
plot(plotting, X1,Y1,'.');
hold(plotting, 'on');
App Code View:
function StartButtonPushed(app, event)
app.UIAxes.Tag = 'plotAxes';
set_param('AppDesignSetup/Sine', 'Amplitude', ...
set_param('AppDesignSetup', 'StopTime',num2str(app.DurationEditField.Value));
set_param('AppDesignSetup', 'SimulationMode', 'normal');
set_param('AppDesignSetup', 'SimulationCommand','start');
I already shared you the documentation for this. Hence I would request you next time please follows the steps provided in the answer and documentation.
Wish you all the best.

Accedi per commentare.

Più risposte (0)

Community Treasure Hunt

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

Start Hunting!

Translated by