How to display the image of a scope in simulink in real time on matlab app designer?

10 Ansichten (letzte 30 Tage)
How to display the image of a scope in simulink in real time on matlab app designer?

Antworten (2)

Umar
Umar am 3 Jul. 2024
Hi HY,
You asked how to display the image of a scope in simulink in real time on matlab app designer?
In order to display the image of a scope in Simulink in real-time on MATLAB App Designer, you can use the following steps:
Create a MATLAB App Designer GUI. Use the imread function to read the image of the scope. Display the image in an Image UI component within the MATLAB App Designer. Continuously update the displayed image using a timer or a loop to reflect real-time changes from Simulink.
For more information on imread function, please refer to
https://www.mathworks.com/help/matlab/ref/imread.html
Hope this will help resolve your problem.
By following these steps, you can visualize the scope image from Simulink in real-time within your MATLAB App Designer interface.

Dinesh
Dinesh am 3 Jul. 2024
Hello.
In order to achieve this, you can make use of "Timer" in App Designer.
I'm assuming that you already have a Simulink model with a "Scope" block. The next step is to log the scope data to the MATLAB Workspace. Here's a documentation link that will help you achieve this: https://www.mathworks.com/help/sldrt/ug/set-scope-parameters-for-logging-to-workspace.html
Next, you can create an app in App Designer and design the app's layout by adding a "UIAxes" component for plotting. In the "Code" tab, create a new function that updates the plot based on workspace variable that has the scope data. Here's a sample function:
function updatePlot(app)
% Get the scope data from MATLAB workspace and plot it
scopeData = evalin('base', 'scopeData');
plot(app.UIAxes, scopeData.Time, scopeData.Data);
end
Now, in the "startupFcn()" function of the app, you can create a timer that runs "updatePlot()" function periodically. "startupFcn()" is a function in App Desginer that runs once every time you open your app.
function startupFcn(app)
% Timer runs updatePlot() once every second
app.Timer = timer('ExecutionMode', 'fixedRate', 'Period', 1, 'TimerFcn', @(~,~)updatePlot(app));
start(app.Timer);
end
Here's a documentation link for "Timer" that might help you: https://www.mathworks.com/help/matlab/creating_guis/wind-speed-gui-in-app-designer.html
By using "Timer", you can update the app in real-time as the MATLAB workspace variable "scopeData" updates when the Simulink model runs.

Kategorien

Mehr zu Develop Apps Using App Designer finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by