How do I update a GUI designed in App Designer with data from a running Simulink model?

S
schlegel · Sep 17, 2021 · 2.6K views
Question
I want to update a GUI that I have designed in App Designer using data that is generated during the simulation of a Simulink model. In other words, how do I access run-time parameters of a Simulink model from App Designer?  
Expert Answer
Profile picture of Prashant Kumar
Prashant Kumar PhD Expert
Answered Aug 28, 2026
Let the Simulink model being used be named "Trial.slx" and the App Designer app being used be named "TrialApp.mlapp". There are three steps involved in accessing run-time parameters of a Simulink model from App Designer. They are listed below:
 
1. In the Simulink model callback "InitFcn" function, define:
hApp = TrialApp;

2. In the Simulink model callback "StartFcn" function, call a function named "updateGUI()" as described below. This method will be called every time the specified block's ("blk") output method executes.

 

blk = 'Trial/DisplayBox';
event = 'PostOutputs';
listener = @(app, event) updateGUI(hApp);
h = add_exec_event_listener(blk, event, listener);

3. Create a public method named "updateGUI()" in the app designed in App Designer. This function will get the specified block's run-time parameters and pass it to the GUI. This function is defined below.

function updateGUI(app, varargin)
     % Create an object that gets the run-time value of the specified block
     rto = get_param([bdroot,'/DisplayBox'],'RuntimeObject');

       % Update the GUI accordingly. In this case a the value of an EditField is being updated.
       app.EditField.Value = rto.InputPort(1).Data;
  end

 

100% Run Guarantee 3-Hour Fast-Track Delivery

Need a Custom Version or Complete Simulation for This Problem?

Our 500+ PhD engineers build, debug, and optimize working MATLAB scripts and Simulink (.slx) models tailored to your exact assignment rubrics with zero plagiarism.

Tested on MATLAB R2024b / R2026a
Turnitin 0% Plagiarism Report
Free 7-Day Revisions Guarantee
Have a different question? Ask here

Get a Free Consultation or a Sample Assignment Review!