| Products & Services | Solutions | Academia | Support | User Community | Company |
| Download Product Updates | | | Get Pricing | | | Trial Software |
| Documentation → Simulink |
| Contents | Index |
| Learn more about Simulink |
| On this page… |
|---|
Modifying Simulation Parameters |
Simulating the model allows you to observe how the thermostat setting and outdoor environment affect the indoor temperature and the cumulative heating cost.
To run the simulation:
In the demo model window, double-click the Scope block named PlotResults.
The software opens a Scope window that contains two axes with the labels "HeatCost" and "Temperatures."
Select Simulation > Start in the model window.
The software simulates the model. As the simulation runs, the cumulative heating cost appears on the "HeatCost" graph at the top of the Scope window. The indoor and outdoor temperatures appear on the "Temperatures" graph as yellow (top) and magenta (bottom) signals, respectively.

One of the most powerful benefits of modeling a system with Simulink is the ability to interactively define the system inputs and observe changes in the behavior of your model. This allows you to quickly evaluate your model and validate the simulation results. This section describes:
Change the thermostat setting to 68 degrees Fahrenheit and observe how the model responds.
To change the thermostat setting:
Double-click the Set Point block in the model window.
The Source Block Parameters dialog box appears.

Enter 68 in the Constant value field.
Click OK.
The software applies your changes.
Select Simulation > Start to rerun the simulation.
The software simulates the model.
Notice that a lower thermostat setting reduces the cumulative heating cost.

Change the average outdoor temperature to 45 degrees Fahrenheit and observe how the model responds.
To change the average outdoor temperature:
Double-click the Avg Outdoor Temp block.
The Source Block Parameters dialog box appears.

Enter 45 in the Constant value field.
Click OK.
The software applies your changes and closes the dialog box.
Select Simulation > Start to rerun the simulation.
The software simulates the model.
Notice that a colder outdoor temperature increases the cumulative heating cost.

Decrease the temperature variation to see how the model responds.
Double-click the Daily Temp Variation block.
The Source Block Parameters dialog box appears.

Enter 5 in the Amplitude field.
Click OK.
The software applies your changes and closes the dialog box.
Select Simulation > Start to rerun the simulation.
The software simulates the model.
In the Scope window, notice that a more stable outdoor temperature alters the frequency with which the heater operates.

Simulink also allows you to import data from the MATLAB workspace to the model's input ports. This allows you to import actual physical data into your model. (For information about other data import capabilities, see Importing Data from a Workspace in the Simulink User's Guide.)
Note In this example, you will create a vector of temperature data in MATLAB, and use that data as an input to the Simulink model. |
To import data from the MATLAB workspace:
In the MATLAB Command Window, create time and temperature data by entering the following commands:
x = (0:0.01:4*pi)'; y = 32 + (5*sin(x)); z = linspace(0,48,1257)';
In the Simulink model window, select the Avg Outdoor Temp block, then press the Delete key to delete it.
Delete the following items from the model in the same way:
Daily Temp Variation block
Two input signal lines to the Sum block
Sum block
The model should now look similar to the following figure. Notice that the output signal from the Sum block changes to a red, dotted line, indicating that it is not connected to a block.

If the Simulink Library Browser is not open, select View > Library Browser in the model window to open it.
Select the Sources library in the Simulink Library Browser.
Select the In1 block in the Simulink Library Browser, then drag it to the model window.
An In1 block appears in the model window.
Connect the dotted line (originally connected to the Sum block) to the In1 block.

Select Simulation > Configuration Parameters in the model window.
The Configuration Parameters dialog box appears.
Select Data Import/Export in the menu on the left side of the dialog box.
The Data Import/Export pane appears.

Select the Input check box in the Load from workspace section.
Enter [z,y] in the Input field.
Click OK.
The software applies your changes and closes the dialog box.
Select Simulation > Start to rerun the simulation.
The software simulates the model.
In the Scope window, notice that the model ran using the imported data, showing colder temperatures and higher heat use.

Once you have completed a model, you may want to export your simulation results to MATLAB for further data analysis or visualization. (See Exporting Data to the MATLAB Workspace for information about additional data export capabilities.)
To export the HeatCost data from the model to the MATLAB workspace:
Select the Sinks library in the Simulink Library Browser.
Select the Out1 block in the Simulink Library Browser, then drag it to the top right of the model window.
An Out1 block appears in the model window.
Draw a branch line from the HeatCost signal line to the Out1 block. For more information, see Drawing a Branch Line.

Select Simulation > Configuration Parameters in the model window.
The Configuration Parameters dialog box appears.
Select Data Import/Export in the menu on the left side of the dialog box.
The Data Import/Export pane appears.

Select the Time check box in the Save to workspace section.
Select the Output check box in the Save to workspace section.
Click OK.
The software applies your changes and closes the dialog box.
Select Simulation > Start to rerun the simulation.
The software simulates the model and saves the time and HeatCost data to the MATLAB workspace.
Notice that the tout and yout variables now appear in the MATLAB workspace.
![]() | Understanding the Demo Model |

Learn more about Simulink through this collection of videos, articles, technical literature and the Getting Started with Simulink Guide.
| © 1984-2009- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |