Main Content

Load and Save External Inputs for a Simulink Model with App Designer

This example shows an app that provides a user interface to load inputs for simulating a model, and then save the simulation output.

Open the Model

The example uses a model of a thermal system of a house.


Open and Examine the App

Open the tuneVariablesAndSaveOutputs.mlapp file to open the app in App Design. The app allows you to load inputs for simulating the model.


The app tuneVariablesAndSaveOutputs is associated with the ex_sldemo_househeat model. To verify this association, go to the

Simulink tab on the toolstrip, in the Model section, verify the model name in the text field. You can also open the model from App Designer by clicking Open Model.

The app tuneVariablesAndSaveOutputs provides a user interface to interact with the ex_sldemo_househeat model. The app contains the following components:

  • Simulation Controls - start, pause, and stop the simulation of the model.

  • Load Input Button - browse and load a mat file with simulation inputs.

  • Save Output Button - save the simulation outputs into a mat file.

  • Variable Tuner - tune and list all the tunable variables in the model.

  • Model Image - display model image.

The Simulink UI components Load Input button, Save Output button, Simulation Controls, and Variable Tuner are all added to the app by dragging and dropping the components from the Simulink section of the Component Library. Simulink UI components automatically connect to the Simulink model associated with the app.

Use the App to Run Simulations

To start using the app, click the Run button from the toolstrip.

Load Inputs

Once you have the app running, you can load different set of external inputs for the simulation. Click Load Input button and select the daily_temp_variation.mat file to load the variables for the simulation. You can see the file name under the Load Input button.

Interact with Tunable Variables

Click Run to start the simulation.

Save Simulation Output

Once the simulation is complete, click Save Output to save simulation outputs to a MAT file.