Main Content

spectrumplot

Plot disturbance spectrum of linear identified models

    Description

    example

    spectrumplot(sys) plots the disturbance spectrum of the model, sys. The software chooses the number of points on the plot and the plot frequency range.

    example

    spectrumplot(sys,line_spec) uses line_spec to specify the line type, marker symbol, and color.

    example

    spectrumplot(sys1,line_spec1,...,sysN,line_specN) plots the disturbance spectrum for one or more models on the same axes.

    You can mix sys, line_spec pairs with sys models as in spectrumplot(sys1,sys2,line_spec2,sys3). spectrumplot automatically chooses colors and line styles in the order specified by the ColorOrder and LineStyleOrder properties of the current axes.

    example

    spectrumplot(ax,___) plots into the axes with handle ax. All input arguments described for the previous syntaxes also apply here.

    example

    spectrumplot(___,plot_options) uses plot_options to specify options such as plot title, frequency units, etc. All input arguments described for the previous syntaxes also apply here.

    example

    spectrumplot(sys,{wmin,wmax}) creates a spectrum plot for frequencies ranging from wmin to wmax.

    example

    spectrumplot(sys,w) uses vector w to specify the plot frequencies.

    example

    h = spectrumplot() returns the handle to the spectrum plot. You use the handle to customize the plot. All input arguments described for the previous syntaxes also apply here.

    Examples

    collapse all

    Obtain the identified model.

    load iddata9 z9
    sys = ar(z9,4);

    Plot the output spectrum for the model.

    spectrumplot(sys);

    Obtain the identified model.

    load iddata9 z9
    sys = ar(z9,4);

    Specify the line width and marker style for the spectrum plot.

    spectrumplot(sys,'k*--');

    'k*--', specifies a dashed line (--) that is black (k), with star markers (*).

    Obtain multiple identified models.

    load iddata9 z9
    sys1 = ar(z9,4);
    sys2 = ar(z9,2);

    Plot the output spectrum for both models.

    spectrumplot(sys1,'b*-',sys2,'g^:');
    legend('sys1','sys2');

    Obtain the axes handle for a plot.

    load iddata9 z9
    sys1 = ar(z9,4);
    spectrumplot(sys1);

    ax = gca;

    ax is the handle for the spectrum plot axes.

    Plot the output spectrum for another model on the specified axes.

    sys2 = ar(z9,2);
    
    hold on;
    spectrumplot(ax,sys2,'r*--');
    
    legend('sys1','sys2');

    Specify the plot options.

    plot_options = spectrumoptions;
    plot_options.FreqUnits = 'Hz';
    plot_options.FreqScale = 'linear';
    plot_options.Xlim = {[0 20]};
    plot_options.MagUnits = 'abs';

    Estimate an AR model.

    load iddata9 z9
    sys = ar(z9,4);

    Plot the output spectrum for the model.

    spectrumplot(sys,plot_options);

    Obtain the identified model.

    load iddata9 z9
    sys = ar(z9,4);

    Specify the frequency range for the output spectrum plot for the model.

    spectrumplot(sys,{1,1000});

    The 2-element cell array {1,1000} specifies the frequency range from 1 rad/s to 1000 rad/s.

    w = [1:100:1000];
    spectrumplot(sys, w);

    The numeric vector w specifies the frequency range from 1 rad/s to 1000 rad/s updating the plot every 100 data points.

    Obtain the identified model.

    load iddata9 z9
    sys = ar(z9,4);

    Get the plot handle for the model spectrum plot.

    h = spectrumplot(sys);

    (Optional) Specify the plot options, using the plot handle.

    setoptions(h,'FreqUnits','Hz','FreqScale','linear','Xlim',{[0 20]},'MagUnits','abs');

    Input Arguments

    collapse all

    Identified linear model, specified as an idpoly object, an idproc object, an idss object, or an idtf object.

    Line style, marker, and color of both the line and marker, specified as a character vector or string. The characters can appear in any order. You do not need to specify all three characteristics (line style, marker, and color). For example, 'b', 'b+:'. See the LineSpec argument of the plot function.

    Example: "blue" specifies a blue solid line

    Example: "r*:" specifies a red dotted line with asterisk markers

    Example: "y" specifies a yellow solid line

    Data Types: char | string

    Plot axes handle for a spectrum plot, returned as a double-precision value.

    You can obtain the current axes handle by using the function, gca.

    Minimum frequency of the frequency range for which to plot the spectrum, specified as a positive number. Specify wmin in rad/TimeUnit, where TimeUnit is sys.TimeUnit.

    For an example of specifying wmin, see Specify Spectrum Plot Frequency Range.

    Maximum frequency of the frequency range for which to plot the spectrum, specified as a positive number. Specify wmax in rad/TimeUnit, where TimeUnit is sys.TimeUnit.

    For an example of specifying wmin, see Specify Spectrum Plot Frequency Range.

    Frequencies for which to plot the spectrum, specified as a vector of positive numbers.

    Specify w in rad/TimeUnit, where TimeUnit is sys.TimeUnit.

    You can use the command, spectrumoptions, to create the plot_options object. For more information, see spectrumoptions.

    Output Arguments

    collapse all

    The plot handle for the generated spectrum plot, returned as a double-precision value.

    Version History

    Introduced in R2012b