| Control System Toolbox™ | ![]() |
| On this page… |
|---|
What is the Linear Simulation Tool? Opening the Linear Simulation Tool Working with the Linear Simulation Tool Example: Loading Inputs from a Microsoft Excel Spreadsheet |
You can use the Linear Simulation Tool to simulate linear models with arbitrary input signals and initial conditions.
The Linear Simulation Tool lets you do the following:
Import input signals from the MATLAB workspace.
Import input signals from a MAT-file, Microsoft® Excel® spreadsheet, ASCII flat-file, comma-separated variable file (CSV), or text file.
Generate arbitrary input signals in the form of a sine wave, square wave, step function, or white noise.
Specify initial states for state-space models.
Default initial states are zero.
To open the Linear Simulation Tool, do one of the following:
In the LTI Viewer, right-click the plot area and select Plot Types > Linear Simulation.
Use the lsim function at the MATLAB prompt:
lsim(modelname)
In the MATLAB Figure window, right-click a response plot and select Input data.
The Linear Simulation Tool contains two tabs, Input signals and Initial states.
After opening the Linear Simulation Tool (as described in Opening the Linear Simulation Tool), follow these steps to simulate your model:
Click the Input signals tab, if it is not displayed.

In the Timing area, specify the simulation time vector by doing one of the following:
Import the time vector by clicking Import time.
Enter the end time and the time interval in seconds. The start time is set to 0 seconds.
Specify the input signal by doing one of the following:
Click Import signal to import it from the MATLAB workspace or a file. For more information, see Importing Input Signals.
Click Design signal to create your own inputs. For more information, see Designing Input Signals.
If you have a state-space model and want to specify initial conditions, click the Initial states tab. By default, all initial states are set to zero.
You can either enter state values in the Initial value column, or import values by clicking Import state vector. For more information about entering initial states, see Specifying Initial Conditions.

For a continuous model, select one of the following interpolation methods in the Interpolation method list to be used by the simulation solver:
You can import input signals from the MATLAB workspace after opening the Linear Simulation Tool (see Opening the Linear Simulation Tool). You can also import inputs from a MAT-file, Microsoft Excel spreadsheet, ASCII flat-file, comma-separated variable file (CSV), or text file.
For information about creating your own inputs, see Designing Input Signals. For an overview of working with the Linear Simulation Tool, see Working with the Linear Simulation Tool.
To import one or more input signals:
In the Linear Simulation Tool, click the Input signals tab, if it is not displayed.
Select one or more rows for the input channels you want to import. The following figure shows an example with two selected channels.

Click Import signal to open the Data Import dialog box. The following figure shows an example of the Data Import dialog box.

In the Import from list, select the source of the input signals. It can be one of the following:
Workspace
MAT file
XLS file
CSV file
ASCII file
Select the data you want to import. The Data Import dialog box contains different options depending on which source format you selected.
For an example of importing input signals, see the following:
To load inputs from a Microsoft Excel (XLS) spreadsheet:
In the Linear Simulation Tool, click Import signal in the Input signals tab to open the Data Import dialog box.
Select the file you want to import and click Open. This populates the Data Import dialog box with the data from the Microsoft Excel spreadsheet.

To load an input signal from the MATLAB workspace:
Enter this code to open a response plot with a second-order system:
s=tf('s');
ss=(s+2)/(s^2+3*s+2);
lsim(ss,randn(100,1),1:100);
Right-click the plot background and select Input data.

This opens the Linear Simulation Tool with default input data.

Create an input signal for your system in the MATLAB Command Window, such as the following:
new_signal=[-3*ones(1,20) 2*ones(1,30) 0.5*ones(1,50)]';
In the Data Import dialog box, click, Assign columns to assign the first column of the input signal to the selected channel.

Click Import. This imports the new signal into the Linear Simulation Tool.

Click Simulate to see the response of your second-order system to the imported signal.

You can generate arbitrary input signals in the form of a sine wave, square wave, step function, or white noise after opening the Linear Simulation Tool (see Opening the Linear Simulation Tool).
For information about importing inputs from the MATLAB workspace or from a file, see Importing Input Signals. For an overview of working with the Linear Simulation Tool, see Working with the Linear Simulation Tool.
To design one or more input signals:
In the Linear Simulation Tool, click the Input signals tab (if it is not displayed).
Specify the simulation time in the Timing area. The time interval (in seconds) is used to evaluate the input signal you design in later steps of this procedure.
Select one or more rows for the signal channels you want to design. The following figure shows an example with two selected channels.

Click Design signal to open the Signal Designer dialog box. The following figure shows an example of the Signal Designer dialog box.

In the Signal type list, select the type of signal you want to create. It can be one of the following:
Sine wave
Square wave
Step function
White noise
Specify the signal characteristics. The Signal Designer dialog box contains different options depending on which signal type you selected.
Click Insert. This brings the new signal into the Linear Simulation Tool.
Click Simulate in the Linear Simulation Tool to view the system response.
If your system is in state-space form, you can enter or import initial states after opening the Linear Simulation Tool (see Opening the Linear Simulation Tool).
For an overview of working with the Linear Simulation Tool, see Working with the Linear Simulation Tool.
You can also import initial states from the MATLAB workspace.
To import one or more initial states:
In the Linear Simulation Tool, click the Initial states tab (if it is not already displayed).
In the Selected system list, select the system for which you want to specify initial conditions.
You can either enter state values in the Initial value column, or import values from the MATLAB workspace by clicking Import state vector. The following figure shows an example of the import window:

After specifying the initial states, click Simulate in the Linear Simulation Tool to view the system response.
![]() | LTI Viewer | Functions for Time and Frequency Response | ![]() |
| © 1984-2008- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |