How can I show Matlab Simulink Data in Matlab App Designer?
93 views (last 30 days)
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! :-)
Jemima Pulipati on 11 Jan 2021
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.