| Control System Toolbox™ | ![]() |
| On this page… |
|---|
When to Use Functions for Time and Frequency Response Time and Frequency Response Functions |
You can use the LTI Viewer GUI for a wide range of applications. There are situations, however, where you may want a more open and extensible environment. You can use the Control System Toolbox functions for basic time and frequency domain analysis plots used in control system engineering. These functions apply to any kind of linear model (continuous or discrete, SISO or MIMO, or arrays of models). You can only apply the frequency domain analysis functions to FRD models.
Use the LTI Viewer when a GUI-driven environment is desirable. On the other hand, use functions when you want customized plots. If you want to include data unrelated to your models, you must use functions instead of the LTI Viewer (which only plots model data).
The next sections discuss time and frequency response functions and how to use these functions to create customized plots of linear model responses.
Time responses investigate the time-domain transient behavior of linear models for particular classes of inputs and disturbances. You can determine such system characteristics as rise time, settling time, overshoot, and steady-state error from the time response. You can use the Control System Toolbox functions for step response, impulse response, initial condition response, and general linear simulations. For example, you can simulate the response to white noise inputs using lsim and the MATLAB function randn.
In addition to time-domain analysis, you can use the Control System Toolbox functions for frequency-domain analysis using the following standard plots:
Bode
Nichols
Nyquist
Singular value
This table lists available time and frequency response functions and their use.
Functions for Frequency and Time Response
Functions | Description |
|---|---|
| bode | Bode plot |
| evalfr | Computes the frequency response at a single complex frequency (not for FRD models) |
| freqresp | Computes the frequency response for a set of frequencies |
| gensig | Input signal generator (for lsim) |
| impulse | Impulse response plot |
| initial | Initial condition response plot |
| iopzmap | Pole-zero map for each I/O pair of an LTI model |
| lsim | Simulation of response to arbitrary inputs |
| margin | Computes and plots gain and phase margins |
| nichols | Nichols plot |
| nyquist | Nyquist plot |
| pzmap | Pole-zero map |
| step | Step response plot |
| hsvd | Compute Hankel singular values of LTI model |
| bodemag | Bode magnitude response of LTI models |
These functions can be applied to single linear models or LTI arrays.
The functions step, impulse, and initial automatically generate an appropriate simulation horizon for the time response plots. For example,
h = tf([1 0],[1 2 10]) impulse(h)
produces the following plot.
Impulse Response of a SISO Model

Frequency-domain plots automatically generate an appropriate frequency range as well.
For MIMO models, time and frequency response functions produce an array of plots with one plot per I/O channel (or per output for initial and lsim). For example,
h = [tf(10,[1 2 10]) , tf(1,[1 1])] step(h)
produces the following plot.
Step Responses for a MIMO Model

The simulation horizon is automatically determined based on the model dynamics. You can override this automatic mode by specifying a final time,
step(h,10) % Simulates from 0 to 10 seconds
or a vector of evenly spaced time samples.
t = 0:0.01:10 % Time samples spaced every 0.01 second step(h,t)
All the time and frequency response functions provide right-click menus that allow you to customize your plots. For more information on using the LTI Viewer right-click menus, see Using the Right-Click Menu in the LTI Viewer. This figure shows the plots from Step Responses for a MIMO Model, with the right-click menu open.
Using the Right-Click Menu in a Step Response Plot

The options you can select include
Systems — Select or clear any models that you included when you created the response plot.
Characteristics — Add information about the plot. The characteristics available change from plot to plot. For example, Bode plots have stability margins available, but step responses have rise time and steady-state values available.
Axes Grouping — Change the grouping of your plots. Available options are All, None, Inputs, and Outputs. You can group all the plots together, place each in a separate plot region (none), or group the inputs or outputs together.
I/O Selector — Open the I/O Selector dialog box.

Use this dialog box to select/clear which inputs and outputs to plot.
Normalize — Scale responses to fit the view (only available for time-domain plot types).
Full View — Use automatic limits to make the entire curve visible.
Grid — Add grids to your plots.
Properties — Open the Property Editor, which you can use to customize various attributes of your plot. See Customization for a full description of the Property Editor.
Alternatively, you can open the Property Editor by double-clicking in an empty region of the response plot.
In addition to right-click menus, you can use plot data markers. These allow you to identify key data points on your plots. This figure, using the same plot as Step Responses for a MIMO Model, shows markers on the plots.
Using Plot Markers to Identify Data Points

You can move a data marker by
Grabbing the black square located at the corner of the marker
Dragging the marker with your mouse
The time and amplitude values will change as you move the marker. This does not apply to markers that display plot characteristics (e.g., peak value or rise time). In the case of plot characteristic data markers, you can view them by placing your cursor over the dot that represents the active characteristic. To make the data marker persistent, left-click the marker.
Note Data markers do not apply to the SISO Design Tool, which displays data about plot characteristics in the status pane at the bottom of the SISO Design Tool window. |
Right-click on any data marker to open a property menu for the marker.

Property options for the marker include
Alignment — Change the position of the marker. Available options are top-right, top-left, bottom-right, and bottom-left.
FontSize — Change the font size.
Movable — By default, you can move data markers by clicking and dragging. Clearing Movable forces the marker to remain at a fixed data point.
Delete — Remove the selected marker. Alternatively, left-click anywhere in the empty plot region to delete all markers in the plot
Interpolation — By default, data markers linearly interpolate between points along the plotted curve. Select None to force the markers to snap to nearest points along the plotted curve.
Since characteristic data markers are by definition fixed, the right-click menus for them have fewer options.

These options work the same as they do for the full right-click menu.
You can use the command-line response-plotting functions to plot the response of continuous and discrete linear models on a single plot. To do so, invoke the corresponding command-line function using the list sys1,..., sysN of models as the inputs.
stepplot(sys1,sys2,...,sysN) impulseplot(sys1,sys2,...,sysN) ... bodeplot(sys1,sys2,...,sysN) nicholsplot(sys1,sys2,...,sysN) ...
All models in the argument lists of any of the response plotting functions (except for sigma) must have the same number of inputs and outputs. To differentiate the plots easily, you can also specify a distinctive color/linestyle/marker for each system just as you would with the plot command. For example,
bodeplot(sys1,'r',sys2,'y--',sys3,'gx')
plots sys1 with solid red lines, sys2 with yellow dashed lines, and sys3 with green x markers.
You can plot responses of multiple models on the same plot. These models do not need to be all continuous-time or all discrete-time.
The following example compares a continuous model with its zero-order-hold discretization.
sysc = tf(1000,[1 10 1000]) sysd = c2d(sysc,0.2) % ZOH sampled at 0.2 second stepplot(sysc,'--',sysd,'-') % Compare step responses
These commands produce the plot shown below.
Comparison of a Continuous Model to Its Discretized Version

Use this command to compare the Bode plots of the two systems.
bodeplot(sysc,'--',sysd,'-') % Compare Bode responses
The following plot results from the last command.
Comparison of Bode Plots for a Continuous Model and Its Discretized Version

A comparison of the continuous and discretized responses reveals a drastic undersampling of the continuous-time system. Specifically, there are hidden oscillations in the discretized time response and aliasing conceals the continuous-time resonance near 30 rad/sec.
Time and frequency response commands are useful for creating custom plots. You can mix model response plots with other data views using response commands together with plot, subplot, and hold.
For example, the following sequence of commands displays the Bode plot, step response, pole/zero map, and some additional data in a single figure window.
h = tf([4 8.4 30.8 60],[1 4.12 17.4 30.8 60]);
subplot(221)
bodeplot(h)
subplot(222)
stepplot(h)
subplot(223)
pzplot(h)
subplot(224)
plot(rand(1, 100)) % Any data can go here
title('Some noise')
Your plot should look similar to this illustration.
Example of Creating a Custom Plot

For information about plot, subplot, hold, and other options for plotting general data, see Basic Plots and Graphs in the MATLAB Function Reference. These documents are available in the MATLAB online help.
Note Each of the plots generated by response analysis functions in Example of Creating a Custom Plot (bodeplot, stepplot, and pzplot) has its own right-click menu (similar to those in the LTI Viewer). To activate the right-click menus, place your mouse in the plot region and right-click. The menu contents depend on what type of plot you have selected. |
![]() | Simulating Models with Arbitrary Inputs and Initial Conditions | Designing Compensators | ![]() |
| © 1984-2008- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |