Estimate Spectral Model
Estimate spectral model using time-domain data in the Live Editor
Open the Task
To add the Estimate Spectral Model task to a live script in the MATLAB Editor:
On the Live Editor tab, select Task > Estimate Spectral Model.
In a code block in your script, type a relevant keyword, such as
spectral
orestimate
. SelectEstimate Spectral Model
from the suggested command completions.
Examples
Parameters
Select DataData Type
— Data type for input and output data
Time
(default) | Data object
The task accepts numeric measurement values that are uniformly sampled in time.
Input and output signals can contain multiple channels. Data can be packaged either as
numeric arrays (for Time
) or in an iddata
object (for Data object
).
The data type you choose determines whether you must specify additional parameters.
Time
— Specify Sample Time in the time unit that you select.Data Object
— Specify no additional parameters because the data object already contains information on time sampling.
Estimation Data
— Estimation data input and output content
Input-output data
(default) | Time series
The task accepts input-output data and time series data that has no input array.
The estimation data content you select, along with your selection of Data Type, determines your options for accessing variables from your MATLAB workspace.
Time series
andInput-output data
— Select the variable names of your input and output vectors for Input (u) and Output (y), respectively. If Data Type isTime series
, then you can select only a single vector, using Output (y).Data object
— Select the variable name of your data object.
Algorithm
— Algorithm to use
SPA (Blackman-Tukey)
(default) | SPAFDR (Frequency-dependent resolution)
| ETFE (Smoothed Fourier transform)
The task provides three algorithms to choose from.
SPA
— Blackman-Tukey Spectral analysis (SPA) method. Takes the Fourier transform of windowed versions of the covariance function.SPAFDR
— Variant of the SPA method that uses frequency-dependent resolution.ETFE
— Empirical transfer function estimate. This method computes the ratio of the Fourier transform of the output to the Fourier transform of the input. For time series, which have no input, this method computes a periodogram as the normalized absolute squares of the Fourier transform of the time series.
For more information on these algorithms, see spa
, spafdr
, and etfe
. For information on selecting an algorithm, see Selecting the Method for Computing Spectral Models.
Window Size or Resolution
— Window size parameter
method-dependent resolution value
Each estimation algorithm uses a unique parameter for determining and using the window size.
SPA
— Hann window size. Specify this parameter as a positive integer greater than 2. The default value is equal to 30 for data arrays with lengths of 300 or more, or, for smaller arrays, arraylength/10.SPAFDR
— Resolution. Specify this parameter in rad/TimeUnit
, whereTimeUnit
is the unit you specify for Sample Time. The resolution is the size of the smallest detail in the frequency function and the spectrum that is resolved by the estimate. Setting the resolution is a tradeoff between obtaining estimates with fine, reliable details, and suffering from spurious, random effects. The default value in the task isdefault
, which uses the resolution thatspafdr
calculates based on the frequencies. If you want to view this resolution value for the SISO modelspectralModel
, at the command line, enterspectralModel.Report.WindowSize
.ETFE
— Hamming window size. Specify this parameter, which represents frequency resolution, as a positive integer greater than 2. The value of the parameter determines the amount of smoothing that the function applies to the raw spectral estimates. The default value in the task isdefault
, which uses the resolution thatetfe
calculates based on the frequencies. If you want to view this resolution value for the SISO modelspectralModel
, at the command line, enterspectralModel.Report.WindowSize
.
Frequency range parameters
— Frequency range minimum, maximum, and units
numeric values | unit string
Specify the frequency vector minimum and maximum, and select the unit, such as the
default rad/second
, from the Unit list.
By default, the task sets the frequency to span the range bounded at the upper end by
the Nyquist frequency, which is a function of the sample time. The task sets the default
value of the lower end of the range to the first frequency value.
Number of frequencies and scale
— Number of frequency divisions and linear or logarithmic scale selection
128 | integer | Logarithmic
| Linear
Specify the number of frequency divisions and whether to use a linear or a
logarithmic scale. The default number of divisions is 128
. The
default scale is Logarithmic
.
Frequency response plot
— Plot the frequency response
on (default) | off
Select Frequency response plot to create a frequency plot of
your model. If you specify your data type as Input-output data
, then
the task creates the frequency response using bode
. If your data type is Time series
, then the task
plots the power spectrum using spectrum
.
You can plot only one model at a time in the task. If you want to compare responses, do one of the following:
Open multiple tasks and visually compare plots for different models.
Use unique model IDs for each model you want to compare, and then create Bode plots for them at the command line.
Frequency response plot parameters
— Magnitude units, scale, confidence region
dB
| Absolute
| Logarithmic
| Linear
| on | off
Specify the parameters for the Bode or power spectrum plot. You can specify that the units in Magnitude are dB or absolute value. For Scale, you can specify a logarithmic or a linear scale for the frequency axis. If you are creating a Bode plot by using input-output data, you can select Show confidence region to display a confidence region of three standard deviations. If you are creating a power spectrum plot by using a time series, no Show confidence region option exists.
Version History
Introduced in R2021b