Read/write Simulink model from within AppDesigner

7 vues (au cours des 30 derniers jours)
Jack Daniels
Jack Daniels le 14 Nov 2022
Modifié(e) : Sai Gokul le 12 Juil 2023
I have a simple Simulink model (application) and I want to use the MATALB App Designer to control simulation, access runtime data and display them in runtime.
How do I acceess running Simulink model in runtime data , in my case: ouput data of the "Reshape" block, signal named as "original MATRIX [3,3]" and output data of "Resize" block named as "resized MATRIX [9,9]" from within App Designer?

Réponses (1)

Sai Gokul
Sai Gokul le 12 Juil 2023
Modifié(e) : Sai Gokul le 12 Juil 2023
Hi Jack,
I understand you want to display the runtime data of a SIMULINK model in a MATLAB App
Here is an approach you can follow
1. Configuring the Output data of a SIMULINK model :
  • Open your Simulink model.
  • In the Simulink Editor, click on the "Simulation" tab.
  • Under the "Model Configuration Parameters" section, click on "Data Import/Export."
  • Configure the data you want to access.
2. Load and run the SIMULINK model in MATLAB App :
  • In MATLAB App create a button to start/stop the model
  • Write a Callback function for the created button with the following code
model = 'myModel';
simOut = sim(model);
3.Access runtime data :
  • To access the runtime data from the Simulink model, you can use the simOut variable. It contains the simulation output, including signals, states, and other data. You can access specific data using the appropriate syntax. For example, in your case to access the signal named 'mySignal', you can use simOut.mySignal.
You can also refer to the following documentation :
Hope this hepls!


En savoir plus sur Programmatic Model Editing dans Help Center et File Exchange




Community Treasure Hunt

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

Start Hunting!

Translated by