- Using Simulink Compiler and the external simulation API for integration with App Designer, or
- Logging simulation data to a buffer and periodically updating the plot during the run (though this would require a more advanced setup).
How do i run the Simulink model and plotting the output from the App designer GUI ....?
7 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti


Hear is the model and GUI App, i want to run model and plot the graph via GUI and during simulation(running ) want to change the variable value, please help me.
Thanks
0 Commenti
Risposte (1)
Ruchika Parag
il 7 Lug 2025
Hi @Vinay, you are on the right path in attempting to control a Simulink model from a custom MATLAB GUI and visualize simulation results. Below is a structured explanation of the correct workflow, as well as considerations when attempting to update simulation inputs dynamically.Recommended Workflow
1. Replacing the Constant Block
To allow external input from the GUI, replace the Constant block in your Simulink model with either a From Workspace block or an Inport block. This enables the model to use a signal defined in the MATLAB base workspace, which can be updated programmatically.
2. Defining the Input Signal
You can define an input signal such as u_val using a timeseries object. For example:
t = 0:0.1:10;
u_val = timeseries(ones(size(t)) * desiredValue, t);
assignin('base', 'u_val', u_val);
This allows your GUI to generate and assign the input signal to the workspace prior to simulation.
3. Running the Simulation from the GUI
The simulation can be executed using the sim function within a callback in your App Designer application. After the simulation concludes, results can be retrieved from the simOut structure and plotted. For instance:
simOut = sim('your_model_name', 'StopTime', '10');
y = simOut.simout.Data;
t = simOut.simout.Time;
plot(app.UIAxes, t, y);
Ensure that your Simulink model includes a To Workspace block labeled simout.Important Considerations
Modifying Inputs During Simulation
Simulink reads variables such as u_val at the start of the simulation. Modifying these values during simulation using assignin will have no effect unless the model is configured to run in external mode or includes Dashboard blocks for interactive control. These features are specifically designed to allow real-time parameter tuning.
Live Plotting During Execution
Using the sim function does not support real-time plotting, as it blocks execution until the simulation completes. For continuous data visualization during simulation, you may consider:
Hope this helps!
0 Commenti
Vedere anche
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!