MATLAB Answers

How can I show Matlab Simulink Data in Matlab App Designer?

조회 수: 88(최근 30일)
Maik Korinek
Maik Korinek 2021년 1월 8일
댓글: Maik Korinek 2021년 1월 19일
Hey guys,
i have an active, functional Matlab Simulink model and want to show/output some datas in Matlab App Designer like a GUI Interface.
How can i do that?
I have found the block "to workspace" but thats not very helpfull, i cant connect it to the App Designer.
If you can, answer detailed.
Thanks for help! :-)
  댓글 수: 1
Mario Malic
Mario Malic 2021년 1월 8일
Everything is possible!
There are many ways to do it, one of suggestions is to create a structure with the data you want to show in App Designer. Let's say you run a simulation and you get results in a variable, or a file. You can call your app and load the file or use the variable from workspace.

댓글을 달려면 로그인하십시오.

채택된 답변

Jemima Pulipati
Jemima Pulipati 2021년 1월 11일
From my understanding, you want to display some outputs of the Simulink model in the App Designer interface.
The most common method of starting a Simulink simulation from MATLAB and then displaying the results is to use the 'sim' function. This function is a blocking function that starts the simulation and then returns an output argument that contains information about the simulation run, such as model outputs, when the simulation is finished.
Please note that the exact format of the output argument will depend on the how the options in the Model Configuration Paramters > Data Import/Export pane are set.
For example if the model is set to 'Save simulation output as single object' then following line of code could be used to run the simulation and report results:
>> simOut = sim(modelName);
When integrating this with a MATLAB App this function call would be placed in the callback function of a button. The button would run the above command and then use the simOut Simulink.SimulationOutput object to display or save results to a file.
Another method of observing the input or output signal to a block while a Simulink simulation is running is to use a Simulink Event Listener. An event listener in Simulink waits for a specific event such as the 'PostOutputs' event which fires just after the outputs of the block are computed. When this event is run Simulink will call the function handle that was provided when the event listener was registered. When the function is called it will be passed variables that can be used to determine input or output values of the block.
An event listener can be registered by using the add_exec_event_listener function.
For more information about this workflow please see the following documentation pages:
The following answers from the community might be of relevance to you.
  댓글 수: 1
Maik Korinek
Maik Korinek 2021년 1월 19일
Thanks for your help, this was helpfull! :-)

댓글을 달려면 로그인하십시오.

추가 답변(0개)

Community Treasure Hunt

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

Start Hunting!

Translated by