MATLAB Simulink
MATLAB Simulink
MATLAB Simulink
Web site,
including Simulink related books, webinars, and technical support.
To access the Simulink product page, go to
http://www.mathworks.com/products/simulink
1-10
2
Simulink Software Basics
Start the Simulink Software on page 2-2
Simulink User Interface on page 2-6
2 Simulink
Software Basics
Start the Simulink Software
In this section...
Open the Simulink Library Browser on page 2-2
Create a New Simulink Model on page 2-4
Open an Existing Model on page 2-5
Open the Simulink Library Browser
You need MATLAB running before you can open the Simulink Library
Browser.
1 In the MATLAB Command Window, enter
simulink
The Simulink Library Browser opens.
2-2
Start the Simulink
Software
You can also open the Simulink Library Browser from the MATLAB Toolstrip,
by clicking the Simulink Library button ( ).
If you have not already loaded Simulink, a short delay occurs while it loads.
The Library Browser opens.
To keep the Library Browser above all other windows on your desktop, in the
Library Browser, select View > Stay on Top.
2-3
2 Simulink
Software Basics
Create a New Simulink Model
Create a new Simulink model from the Simulink Library Browser.
1 From the Simulink Library Browser menu, select File > New > Model.
An empty model opens in the Simulink Editor.
2 In the Simulink Editor, select File > Save.
3 In the Save As dialog box, enter a name for your model, and then click Save.
Simulink saves your model.
2-4
Start the Simulink
Software
Open an Existing Model
Open an existing Simulink model from the Simulink Library Browser.
1 From the Simulink Library Browser menu, select File > Open.
2 In the Open dialog box, select the model file that you want to open, and
then click Open.
The selected model opens in the Simulink Editor. For example:
Alternatively, in MATLAB you can set the current folder to the folder
containing your model, and then in the MATLAB Command Window, enter
the model name without the filename extension.
2-5
2 Simulink
Software Basics
Simulink User Interface
In this section...
Simulink Library Browser on page 2-6
Simulink Editor on page 2-9
Simulink Library Browser
The Simulink Library Browser displays the block libraries installed on your
computer. You start to build models by copying blocks from a library into a
Simulink Editor model window.
For example, in the Library Browser below:
In the Libraries pane on the left, the Sources library is the selected library.
The Sine Wave block is selected.
2-6
Simulink
User Interface
Tips for Using the Library Browser
You can perform several tasks using the Library Browser, including the
following.
Task Action to Perform Using the Library
Browser
View the blocks in a library In the left pane, select a library name, or in
the right pane, double-click a library icon.
Search for a specific block In the block search field, enter the name of
a block, and then click the find block icon
.
Get summary information
about a block
Select View > Show Block Descriptions.
Then select the block.
Get detailed information
about a block
Select the block, and then select Help >
Help for the Selected Block. The Help
browser opens with the reference page for
the block.
View block parameters Right-click a block, and then select Block
parameters.
Copy a block from the Library
Browser to a model
Drag a block from the Library Browser to a
Simulink Editor model window.
Standard Block Libraries
Simulink software includes the following standard block libraries.
Block Library Description
Commonly Used
Blocks
Group of the most commonly used blocks, such as
the Constant, In1, Out1, Scope, and Sum blocks.
Each of the blocks in this library are also included in
other libraries.
Continuous Model linear functions using blocks such as the
Derivative and Integrator blocks.
2-7
2 Simulink
Software Basics
Block Library Description
Discontinuities Create outputs that are discontinuous functions of
their inputs using blocks such as the Saturation
block.
Discrete Represent discrete time functions using blocks such
as the Unit Delay block.
Logic and Bit
Operations
Perform logic or bit operations using blocks such as
the Logical Operator and Relational Operator
blocks.
Lookup Tables Use lookup tables to determine their outputs from
their inputs using blocks such as the Cosine and
Sine blocks.
Math Operations Perform mathematical and logical functions using
blocks such as the Gain, Product, and Sum blocks.
Model
Verification
Create self-validating models using blocks such as
the Check Input Resolution block.
Model-Wide
Utilities
Provide information about the model using blocks
such as the Model Info block.
Ports &
Subsystems
Create subsystems using blocks such as the In1,
Out1, and Subsystem blocks.
Signal Attributes Modify the attributes of signals using blocks such as
the Data Type Conversion block.
Signal Routing Route signals from one point in a block diagram to
another using blocks such as the Mux and Switch
blocks.
Sinks Display or export output using blocks such as the
Out1 and Scope blocks.
Sources Generate or import system inputs using blocks such
as the Constant, In1, and Sine Wave blocks.
User-Defined
Functions
Define custom functions using blocks such as the
MATLAB Function block.
Additional Math
& Discrete
Additional libraries for mathematical and discrete
function blocks.
2-8
Simulink
User Interface
Simulink Editor
The Simulink Editor contains a block diagram of your model. You build
models by dragging blocks from the Simulink Library Browser window to
the Simulink Editor model window. In the model window, you build a block
diagram by arranging the blocks logically, connecting the blocks with signal
lines, and setting the parameters for each block.
You also use the Simulink Editor to:
Set configuration parameters for the model, including the start and stop
time, type of solver to use, and data import/export settings.
Start and stop a simulation of the model.
Save the model.
Print the block diagram.
2-9
2 Simulink
Software Basics
2-10
3
Simple Simulink Model
3 Simple Simulink
Model
Create a Simple Model
In this section...
Model Overview for This Tutorial on page 3-3
Open the Simulink Library Browser on page 3-4
Browse or Search for Specific Blocks on page 3-5
Open the Simulink Editor on page 3-6
Add Blocks to a Model on page 3-7
Move and Resize Blocks on page 3-8
Simulink Block Connections on page 3-9
Draw Signal Lines Between Blocks on page 3-9
Draw Branched Signal Lines on page 3-12
Define Simulation Parameters on page 3-14
Run Simulation on page 3-14
Observe Simulation Results on page 3-15
3-2
Create a Simple Model
Model Overview for This Tutorial
You can use Simulink to model a system and then simulate the dynamic
behavior of that system. The basic techniques you use to create a simple model
in this tutorial are the same techniques that you use for more complex models.
To create this simple model, you need four blocks:
Sine Wave Generates an input signal for the model.
Integrator Processes the input signal.
Bus Creator Combines the input signal and processed signal into
one signal.
Scope Visualizes the signals.
Simulating this model integrates a sine wave signal to a cosine signal and
then displays the result, along with the original signal, in a scope window.
3-3
3 Simple Simulink
Model
Open the Simulink Library Browser
From the Simulink Library Browser, you can create a new model (block
diagram) and search for blocks that you want to use in your model. You need
MATLAB running before you can open the Simulink Library Browser.
1 From the MATLAB Toolstrip, click the Simulink Library button , or
in the Command Window, enter
simulink
A short delay occurs before the Simulink Library Browser opens.
2 In the Simulink Library Browser, select View > Stay on Top to keep the
Library Browser on top of the other windows on your desktop.
3-4
Create a Simple Model
Browse or Search for Specific Blocks
To browse through the block libraries, select a MathWorks product, and then
select a functional area. Alternatively, you can search all of the available
block libraries at once.
1 Browse for the block. In the Libraries pane on the left, select Simulink,
and then select the Sources library. From the Library displayed in the
right pane, select the Sine Wave block.
2 Search for a block. In the search box, enter a block name or part of a block
name. For example, enter sine, and then click the Search button .
3 Get detailed information about a block. Select the block, and then from the
menu bar, select Help > Help for the Selected Block. The Help browser
opens with the reference page for that block.
4 View block parameters. Right-click a block, and then select Block
Parameters. The block parameters dialog box opens.
3-5
3 Simple Simulink
Model
Open the Simulink Editor
In the Simulink Editor, you can build and simulate models of your system.
You need the Simulink Library Browser open before you can create a new
Simulink model.
1 From the Simulink Library Browser Toolstrip, click the New Model button
, or from the menu bar, select File > New > Model.
A Simulink Editor window opens with an new block diagram in the right
pane.
2 Select File > Save as. In the File name text box, enter a name for your
model. For example, enter simple_model, and then click Save.
Simulink saves your model with the file name simple_model.slx.
3-6
Create a Simple Model
Add Blocks to a Model
To build a model, begin by copying blocks from the Simulink Library Browser
to the Simulink Editor.
1 In the Simulink Library Browser, select the Sources library. The Library
Browser displays blocks from the selected library in the right pane.
2 Select the Sine Wave block, and then drag the block to the block diagram.
A copy of the Sine Wave block appears in your model.
3-7
3 Simple Simulink
Model
3 Add the following blocks to your model, using the same approach that you
used to add the Sine Wave block.
Library Block
Sinks Scope
Continuous Integrator
Signal Routing Bus Creator
Your model now has the blocks you need for the simple model.
Move and Resize Blocks
Before you connect the blocks in your model, arrange them logically to make
the signal connections as straightforward as possible.
1 Move the Scope block after the Bus block output. You can either:
Click and drag a block.
Select the block, and then press the arrow keys on your keyboard.
2 Move the Sine Wave and Integrator blocks before the Bus block.
3-8
Create a Simple Model
Move the blocks until your model looks similar to the following figure.
Simulink Block Connections
After you add blocks to your model, you need to connect them. The connecting
lines represent the signals within your model.
Most blocks have angle brackets on one or both sides. These angle brackets
represent input and output ports:
The > symbol pointing into a block is an input port.
The > symbol pointing out of a block is an output port.
Input port Output port
Draw Signal Lines Between Blocks
Connect the blocks by drawing lines between output ports and input ports.
3-9
3 Simple Simulink
Model
1 Position the cursor over the output port on the right side of the Sine Wave
block.
The pointer changes to a cross hair (+) while over the port.
2 Click, and then drag a line from the output port to the top input port
of the Bus block.
While you are holding down the mouse button, the connecting line appears
as a red dotted arrow.
3 Release the mouse button when the pointer is over the output port.
3-10
Create a Simple Model
Simulink connects the blocks with a line and an arrow indicating the
direction of signal flow.
4 Connect the output port of the Integrator block to the bottom input port on
the Bus block using this alternative procedure:
a Select the Integrator block.
b Press and hold the Ctrl key.
c Click the Bus block.
The Integrator block connects to the Bus block with a signal line.
Note The Ctrl+click shortcut is useful when you are connecting widely
separated blocks or when working with complex models.
3-11
3 Simple Simulink
Model
5 Connect the Bus block output port to the Scope block.
Draw Branched Signal Lines
Your simple model is almost complete. To finish the model, connect the Sine
Wave block to the Integrator block.
This connection is different from the other connections, which all connect
output ports to input ports. Because the output port of the Sine Wave block is
already connected, you must connect this existing line to the input port of the
Integrator block. The new line, called a branch line, carries the same signal
that passes from the Sine Wave block to the Bus block.
1 Hold down the Ctrl key.
2 Position the cursor where you want to start a branch line. Click, and then
drag the cursor away from the line to form a dotted-red line segment.
3-12
Create a Simple Model
3 Drag the cursor to the Integrator input port, and then release the mouse
button.
4 Drag line segments to straighten and align with blocks. Your model is
now complete.
3-13
3 Simple Simulink
Model
Define Simulation Parameters
Before you simulate the behavior of a model, define the simulation
parameters. Simulation parameters include the type of numerical solver,
start and stop times, and maximum step size.
1 From the Simulink Editor menu, select Simulation > Model
Configuration Parameters. The Configuration Parameters dialog box
opens to the Solver pane.
2 In the Stop time field, enter 20. In the Max step size field, enter 0.2.
3 Click OK.
Run Simulation
After you define Model Configuration Parameters, you are ready to simulate
your model.
1 From the Simulink Editor menu bar, select Simulation > Run.
The simulation runs, and then stops when it reaches the stop time specified
in the Model Configuration Parameters dialog box.
Tip Alternatively, you can control a simulation by clicking the Run
simulation button and Pause simulation button on the
Simulink Editor toolbar.
3-14
Create a Simple Model
Observe Simulation Results
After simulating a model you can view the simulation results in a Scope
window.
1 Double-click the Scope block.
The Scope window opens and displays the simulation results. The plot
shows a sine wave signal with the resulting cosine wave signal from the
Integrator block.
2 From the Scope block toolbar, click the Parameters button . Select the
Style tab. The Scope Parameters dialog box displays figure editing options.
3-15
3 Simple Simulink
Model
3 Change the appearance of the figure. For example, select white for the
Figure color and Axes background color (icons with a pitcher) and black
for the Ticks, labels and grid colors (icon with a paintbrush). Change the
signal line colors for signal 1 to blue and for signal 2 to green. To see your
changes, click OK.
4 Select File > Close > Close Model. The Simulink Editor closes with
changes to your model and the model configuration parameters.
3-16
4
Modeling a Dynamic
Control System
Dynamic Control System Model on page 4-2
Anatomy of the Control System Model on page 4-3
Simulate the Control System Model on page 4-12
Move Data Between MATLAB and Simulink Model on page 4-18
4 Modeling a Dynamic Control System
Dynamic Control System Model
This tutorial uses the sldemo_househeat model to illustrate how you can use
Simulink software to model a dynamic control system. The model defines a
heating system and the thermodynamics of a house. It includes the outdoor
environment, the thermal characteristics of a house, and the house heating
system.
Use this tutorial to explore common Simulink modeling tasks, such as:
Simplify a block diagram by grouping multiple blocks into a single
subsystem block.
See Anatomy of the Control System Model on page 4-3.
Simulate a model, observe results, and change input parameters to
investigate how the system responds.
See Simulate the Control System Model on page 4-12.
Import data from the MATLAB workspace to the model, and export
runtime data back to MATLAB.
See Move Data Between MATLAB and Simulink Model on page 4-18.
4-2
Anatomy of the Control System Model
Anatomy of the Control System Model
In this section...
Overview of the Example Model on page 4-3
Subsystems in the Example Model on page 4-5
Subsystems and Masks on page 4-8
Creating a Subsystem on page 4-9
Create a Subsystem Mask on page 4-11
Overview of the Example Model
The model for this example is called sldemo_househeat. It models the
heating system and thermodynamics of a house.
1 Start MATLAB, and then in the MATLAB Command Window, enter
sldemo_househeat
The Simulink Editor opens with the example model.
4-3
4 Modeling a Dynamic Control System
The sldemo_househeat model defines the dynamics of the outdoor
environment, the thermal characteristics of the house, and the house heating
system. It allows you to simulate how the thermostat setting and outdoor
environment affect the indoor temperature and cumulative heating costs.
The example model includes many of the same blocks you used to create the
simple model in Create a Simple Model on page 3-2. These blocks include:
A Scope block (labeled PlotResults) on the far right displays the
simulation results.
A Mux block at the bottom right combines the indoor and outdoor
temperature signals for the Scope.
A Sine Wave block (labeled Daily Temp Variation) at the bottom left
provides one of three data sources for the model.
In the model, the thermostat is set to 70 degrees Fahrenheit. Fluctuations in
outdoor temperature are modeled by applying a sine wave with amplitude of
15 degrees to a base temperature of 50 degrees.
The three data inputs (sources) are provided by two Constant blocks (labeled
Set Point and Avg Outdoor Temp), and the Sine Wave block (labeled Daily
Temp Variation). The Scope block labeled PlotResults is the one output
(sink).
4-4
Anatomy of the Control System Model
Subsystems in the Example Model
A subsystem is a hierarchical grouping of blocks encapsulated by a single
Subsystem block. The sldemo_househeat model uses subsystems to:
Simplify the appearance of the block diagram
Create reusable components
Customize the appearance of blocks
The example model uses the following subsystems: Thermostat, Heater,
House, Fahrenheit to Celsius, and Celsius to Fahrenheit.
1 In the MATLAB Command Window, enter
sldemo_househeat
The example model opens in the Simulink Editor model window.
4-5
4 Modeling a Dynamic Control System
Tip You can use content preview to display a representation of the contents
of a subsystem, without opening the subsystem. Content preview helps
you to understand at a glance the kind of processing performed by the
subsystem. For details, see Preview Content of Hierarchical Items.
2 Subsystems can be complex and contain many blocks that might otherwise
clutter a diagram. For example, to open the House subsystem, double-click
the House Subsystem block.
The House subsystem receives heat flow and external temperature as
inputs, which it uses to compute the current room temperature. You could
leave each of these blocks at the top level of the main sldemo_househeat
model, but combining them as a subsystem helps to simplify the block
diagram.
4-6
Anatomy of the Control System Model
3 A subsystem can also be simple and contain only a few blocks. For example,
to open the Thermostat subsystem:
a Display the sldemo_househeat top model. To do so, in the tabs at
the top of the model window, ( ), click
sldemo_househeat. The sldemo_househeat model appears in the model
window.
b Double-click the Thermostat Subsystem block.
This subsystem models the operation of a thermostat, determining when
the heating system is on or off. It contains only one Relay block, but
logically represents the thermostat in the block diagram.
4-7
4 Modeling a Dynamic Control System
Subsystems and Masks
The sldemo_househeat model contains two instances of identical subsystems
named Fahrenheit to Celsius. These subsystems convert the inside and
outside temperatures from degrees Fahrenheit to degrees Celsius.
1 Display the sldemo_househeat model, by selecting sldemo_househeat in
the tabs at the top of the Simulink Editor model window.
2 Double-click the Fahrenheit to Celsius masked Subsystem block. The
custom dialog box for the F2C block opens.
Click OK.
3 To view the underlying blocks in the Fahrenheit to Celsius conversion
subsystem, select the Fahrenheit to Celsius Subsystem block and then
select Diagram > Mask > Look Under Mask.
The Simulink Editor displays the blocks behind the mask.
4-8
Anatomy of the Control System Model
Creating a Subsystem
Subsystems allow you to group related blocks into one block. They are also
reusable, enabling you to implement an algorithm once and use it multiple
times.
To create a subsystem:
1 Display the sldemo_househeat model, by selecting sldemo_househeat in
the tabs at the top of the Simulink Editor model window.
2 In the model window, click and drag a bounding box around the Set Point
and Fahrenheit to Celsius blocks.
4-9
4 Modeling a Dynamic Control System
3 From the Simulink Editor menu, select Diagram > Subsystem &
Modeling Reference > Create Subsystem from Selection.
The blocks are combined into one subsystem block.
For more information about working with subsystems, see Create a
Subsystem.
4-10
Anatomy of the Control System Model
Create a Subsystem Mask
You can customize the appearance of a subsystem by using a process known
as masking. Masking a subsystem allows you to specify a unique icon and
dialog box for the Subsystem block. For example, the House and Thermostat
subsystems display custom icons that depict physical objects, while the
conversion subsystems display custom dialog boxes when you double-click
the blocks.
To mask a subsystem:
1 In the model window, right-click the new subsystem block (as described in
Creating a Subsystem on page 4-9). In the context menu, select Mask >
Create Mask. The Mask Editor dialog box opens.
2 At the bottom of the Mask Editor dialog box, expand the Command list.
Select disp (show text in center of block). The dialog box displays
the syntax for this command below the list.
3 In the Icon Drawing commands field, enter disp('Select
Temperature').
4 Click OK. The subsystem block displays the text that you entered.
To see the full text in the block icon, select a corner of the block and drag to
expand the size of the block.
For more information about masking subsystems, see Masking.
4-11
4 Modeling a Dynamic Control System
Simulate the Control System Model
In this section...
Run the Simulation on page 4-12
Change the Thermostat Setting on page 4-13
Change the Average Outdoor Temperature on page 4-15
Change the Daily Temperature Variation on page 4-16
Run the Simulation
Simulating the sldemo_househeat model allows you to observe how the
thermostat setting and outdoor environment affect the indoor temperature
and the cumulative heating cost.
1 In the sldemo_househeat model window, double-click the Scope block
named PlotResults. A Scope window opens with two axes labeled
HeatCost and Temperatures.
2 In the Simulink Editor, select Simulation > Run.
The software simulates the model dynamics, and as the simulation runs,
it displays the results in a Scope window. The cumulative heating cost
is drawn on the HeatCost graph. The indoor and outdoor temperatures
appear on the Temperatures graph.
4-12
Simulate the Control System Model
Change the Thermostat Setting
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.
Change the thermostat setting to 68 degrees Fahrenheit and observe how
the model responds.
1 In the sldemo_househeat model window, open the masked Subsystem
block (the block icon that displays the text Select Temperature).
2 In the Subsystem model window, double-click the Set Point block. The
Source Block Parameters dialog box opens.
3 In the Constant value field, enter 68.
4-13
4 Modeling a Dynamic Control System
4 Click OK. The software applies your changes and closes the dialog box.
5 To rerun the simulation, you can either select Simulation > Run, or from
the toolbar, you can use the Run button ( ). The software simulates
the model dynamics. Notice that a lower thermostat setting reduces the
cumulative heating cost.
4-14
Simulate the Control System Model
Change the Average Outdoor Temperature
Change the average outdoor temperature to 45 degrees Fahrenheit and
observe how the model responds.
1 In the sldemo_househeat model window, double-click the Avg Outdoor
Temp block. The Source Block Parameters dialog box opens.
2 In the Constant value field, enter 45.
3 Click OK. The software applies your changes.
4 Rerun the simulation.
The software simulates the model dynamics. Notice that a colder outdoor
temperature increases the cumulative heating cost.
4-15
4 Modeling a Dynamic Control System
Change the Daily Temperature Variation
Decrease the temperature variation to see how the model responds.
1 In the sldemo_househeat model window, double-click the Daily Temp
Variation block. The Source Block Parameters dialog box opens.
2 In the Amplitude field, enter 5.
3 Click OK. The software applies your changes.
4 Rerun the simulation.
The software simulates the model dynamics. Notice that a more stable
outdoor temperature alters the frequency with which the heater operates.
4-16
Simulate the Control System Model
4-17
4 Modeling a Dynamic Control System
Move Data Between MATLAB and Simulink Model
In this section...
Import Data from the MATLAB Workspace on page 4-18
Export Simulation Data to the MATLAB Workspace on page 4-22
Import Data from the MATLAB Workspace
You can import data from the MATLAB workspace to the Simulink model
input ports. This allows you to import actual physical data into your model.
For information about other data import capabilities, see Import Data.
In this example, you 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:
1 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)';
y is a vector of outdoor temperatures that varies from 27 to 37 degrees
Fahrenheit. z is a time vector from 0 to 48. Both vectors contain 1257
values.
2 In the Simulink Editor model window, select the Avg Outdoor Temp block,
and then press the Delete key to remove it from the model.
3 Delete the following items from the model in the same way:
Daily Temp Variation block
Two input signal lines to the Sum1 block
Sum1 block
4-18
Move Data Between MATLAB
and Simulink
Model
The model should now look similar to the following figure. Notice that the
output signal from the Sum1 block changes to a red, dotted line, indicating
that it is not connected to a block.
4 In the model window, select View > Library Browser. The Simulink
Library Browser window opens.
5 In the Library Browser, in the Libraries pane, select the Sources library.
6 From the Sources library in the right pane, select the In1 block, and then
drag it to the Simulink Editor model window.
An instance of the In1 block appears in the model window.
7 Connect the dotted line (originally connected to the Sum1 block) to the In1
block.
4-19
4 Modeling a Dynamic Control System
8 In the Simulink Editor, select Simulation > Model Configuration
Parameters.
9 From the menu on the left side of the Configuration Parameters dialog
box, select Data Import/Export.
10 On the Data Import/Export pane, select the Input check box. In the
Input field, enter [z,y].
4-20
Move Data Between MATLAB
and Simulink
Model
11 Click OK. The software applies your changes and closes the dialog box.
12 Rerun the simulation.
The software simulates the model. Notice that the model ran using the
imported data, showing colder outdoor temperatures and higher heat use.
4-21
4 Modeling a Dynamic Control System
Export Simulation Data to the MATLAB Workspace
Once you complete a model, you may want to export your simulation results
to the MATLAB workspace for further data analysis or visualization. For
information about additional data export capabilities, see Export Runtime
Information.
To export the HeatCost data from the model to the MATLAB workspace:
1 In the Simulink Library Browser, select the Sinks library.
2 From the Sinks library, select the Out1 block, and then drag it to the top
right of the Simulink Editor model window.
An instance of the Out1 block appears in the model window.
3 Draw a branch line from the HeatCost signal line to the Out1 block.
4-22
Move Data Between MATLAB
and Simulink
Model
4 Select Simulation > Model Configuration Parameters.
5 From the menu on the left side of the Configuration Parameters dialog
box, select Data Import/Export.
6 On the Data Import/Export pane, select the Time and Output check
boxes.
4-23
4 Modeling a Dynamic Control System
7 Click OK. The software applies your changes and closes the dialog box.
8 Rerun the simulation.
The software simulates the model and saves the time and HeatCost data to
the MATLAB workspace in the variables tout and yout.
4-24
5
Basic Simulation Workflow
5 Basic Simulation Workflow
Simulation with Data Import and Signal Inspection
In this section...
Data Import and Logging Workflow on page 5-2
Example Used in this Tutorial on page 5-3
Import Signal Data on page 5-4
Simulate Model on page 5-11
Compare Signals on page 5-14
Create, Save, and Print a Figure on page 5-15
Data Import and Logging Workflow
Simulink provides two features to import data and view simulation results:
the Signal Builder block and the Simulation Data Inspector. Use the Signal
Builder block to import input signals into your model. The Simulation Data
Inspector allows you to view model output signals and compare them.
A typical workflow includes the following steps:
1 Import signal data from a Microsoft
Excel