This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

How to Plot Data at the Command Line

The following table summarizes the commands available for plotting time-domain, frequency-domain, and frequency-response data.

Commands for Plotting Data

CommandDescriptionExample
bode, bodeplot

For frequency-response data only. Shows the magnitude and phase of the frequency response on a logarithmic frequency scale of a Bode plot.

To plot idfrd data:

bode(idfrd_data)

or:

bodeplot(idfrd_data)
plot

The type of plot corresponds to the type of data. For example, plotting time-domain data generates a time plot, and plotting frequency-response data generates a frequency-response plot.

When plotting time- or frequency-domain inputs and outputs, the top axes show the output and the bottom axes show the input.

To plot iddata or idfrd data:

plot(data)

All plot commands display the data in the standard MATLAB® Figure window, which provides options for formatting, saving, printing, and exporting plots to a variety of file formats.

To plot portions of the data, you can subreference specific samples (see Select Data Channels, I/O Data and Experiments in iddata Objects and Select I/O Channels and Data in idfrd Objects. For example:

plot(data(1:300))

For time-domain data, to plot only the input data as a function of time, use the following syntax:

plot(data(:,[],:)

When data.intersample = 'zoh', the input is piece-wise constant between sampling points on the plot. For more information about properties, see the iddata reference page.

You can generate plots of the input data in the time domain using:

plot(data.SamplingInstants,data.u)

To plot frequency-domain data, you can use the following syntax:

semilogx(data.Frequency,abs(data.u))

When you specify to plot a multivariable iddata object, each input-output combination is displayed one at a time in the same MATLAB Figure window. You must press Enter to update the Figure window and view the next channel combination. To cancel the plotting operation, press Ctrl+C.

Tip

To plot specific input and output channels, use plot(data(:,ky,ku)), where ky and ku are specific output and input channel indexes or names. For more information about subreferencing channels, see Subreferencing Data Channels.

To plot several iddata sets d1,...,dN, use plot(d1,...,dN). Input-output channels with the same experiment name, input name, and output name are always plotted in the same plot.

Related Topics