How can I update a App designer with values from my Simulink model as it is running?

20 views (last 30 days)
I have Display block in simulink that can display a value, I wonder if there is anyway I could read that data from simulink and display it on Matlab App designer.

Answers (1)

Atharva
Atharva on 12 Sep 2023
Hi Sarvesh,
I understand you are trying to read the data from Simulink and display it on MATLAB App Designer in read-time.
To do this, you can use the MATLAB Simulink API and MATLAB App Designer's capabilities to create a custom interface.
Here are the general steps to achieve this:
  1. Create a Simulink Model: Make sure you have a Simulink model that generates the data you want to display in your MATLAB App.
  2. Simulink to MATLAB Interface: You can use MATLAB's Simulink API to interact with your Simulink model. Specifically, you can use the sim function to run simulations and extract data from Simulink.
% Simulate the Simulink model
simOut = sim('YourSimulinkModel');
% Extract data from Simulink model
simData = simOut.yourOutputSignal; % Replace 'yourOutputSignal' with the signal you want to read
3.Create a MATLAB App: Create a new MATLAB App using App Designer. You can use App Designer's UI components to create the interface for displaying the data.
4.Update App with Simulink Data: Inside your MATLAB App's code, you can update the UI components with the data obtained from Simulink. For example, if you want to display the data in a text box, you can use a Label component and update its text property.
% Update the Label component with Simulink data
app.YourLabel.Text = num2str(simData);
5.Running the App: You can run your MATLAB App and use it to display the data obtained from Simulink in real-time.
I hope this helps!

Categories

Find more on Develop Apps Using App Designer 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!