Functions for Time and Frequency Response

When to Use Functions for Time and Frequency Response

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 and Frequency Response Functions

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:

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.

Plotting MIMO Model Responses

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)

Right-Click Menus

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

Data Markers

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

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.

Right-Click Menus

Right-click on any data marker to open a property menu for the marker.

Property options for the marker include

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.

Plotting and Comparing Multiple Systems

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.

Example: Comparing Continuous and Discretized Systems

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.

Creating Custom Plots

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.

Example: Custom Plots

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.

  


 © 1984-2008- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS