How to display the image of a scope in simulink in real time on matlab app designer?
조회 수: 11 (최근 30일)
이전 댓글 표시
How to display the image of a scope in simulink in real time on matlab app designer?
댓글 수: 0
답변 (2개)
Umar
2024년 7월 3일
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.
댓글 수: 0
Dinesh
2024년 7월 3일
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
Here's the documentation link for "startupFcn()": https://www.mathworks.com/help/matlab/creating_guis/app-designer-startup-function.html
By using "Timer", you can update the app in real-time as the MATLAB workspace variable "scopeData" updates when the Simulink model runs.
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Develop Apps Using App Designer에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!