Main Content


Estimate frequency response and spectrum using spectral analysis with frequency-dependent resolution


g = spafdr(data)
g = spafdr(data,Resol,w)
g = spafdr(___,Name-Value)


g = spafdr(data) estimates the input-to-output frequency response G(ω) and noise spectrum Φυ of the general linear model


where Φυ(ω) is the spectrum of υ(t).

data contains time-domain or frequency-domain input/output data or time series data. data can be in the form of a timetable, a comma-separated pair of numeric matrices, or an iddata object. The data can be complex valued and in the time domain or frequency domain. If there are multiple experiments, data can be a cell array.

data can also be an idfrd object containing frequency-response data. g is an idfrd object with the estimate of G(eiω) at the frequencies ω specified by row vector w.

g also includes information about the spectrum estimate of Φυ(ω) at the same frequencies. Both results are returned with estimated covariances, included in g. The normalization of the spectrum is the same as described in spa.

Information about the estimation results and options used is stored in the model's Report property. Report has the following fields:

  • Status — Summary of the model status, which indicates whether the model was created by construction or obtained by estimation.

  • Method — Estimation command used.

  • WindowSize — Frequency resolution.

  • DataUsed — Attributes of the data used for estimation. Structure with the following fields:

    • Name — Name of the data set.

    • Type — Data type.

    • Length — Number of data samples.

    • Ts — Sample time.

    • InterSample — Input intersample behavior.

    • InputOffset — Offset removed from time-domain input data during estimation.

    • OutputOffset — Offset removed from time-domain output data during estimation.

g = spafdr(data,Resol,w) specifies frequencies and frequency resolution.

g = spafdr(___,Name-Value) uses additional model options specified by one or more name-value arguments.

The available arguments consist of:

  • InputName and OutputName — Input and output channel names. Use these arguments especially when data is a timetable that has more variables than you want to use. Also use OutputName to identify the output channels when the timetable data contains more than one output variable. Otherwise, the software interprets only the last variable as an output channel.

    For example, specify the input and output signal variable names using sys = spafdr(data,'InputName',["u1","u3"],'OutputName',["y1","y4"]). You can use this syntax with any of the previous input-argument combinations.

  • Ts and TimeUnit — Sample time and time units. Use these arguments especially when you are data contains numeric matrices, which do not provide sample-time information.


The frequency variable w is either specified as a row vector of frequencies in rad/TimeUnit, where TimeUnit refers to the TimeUnit property of data, or as a cell array {wmin,wmax}. In the latter case the covered frequencies will be 50 logarithmically spaced points from wmin to wmax. You can change the number of points to NP by entering {wmin,wmax,NP}.

Omitting w or entering it as an empty matrix gives the default value, which is 100 logarithmically spaced frequencies between the smallest and largest frequency in data. For time-domain data, the default range goes from 2πNTs to πTs, where Ts is the sample time of data and N is the number of data points.


The argument Resol defines the frequency resolution of the estimates. The resolution (measured in rad/TimeUnit) is the size of the smallest detail in the frequency function and the spectrum that is resolved by the estimate. The resolution is a tradeoff between obtaining estimates with fine, reliable details, and suffering from spurious, random effects: The finer the resolution, the higher the variance in the estimate. Resol can be entered as a scalar (measured in rad/TimeUnit), which defines the resolution over the whole frequency interval. It can also be entered as a row vector of the same length as w. Then Resol(k) is the local, frequency-dependent resolution around frequency w(k).

The default value of Resol, obtained by omitting it or entering it as the empty matrix, is Resol(k) = 2(w(k+1)-w(k)), adjusted upwards, so that a reasonable estimate is guaranteed. In all cases, the resolution is returned in the variable g.Report.WindowSize.


If the data is given in the time domain, it is first converted to the frequency domain. Then averages of Y(w)Conj(U(w)) and U(w)Conj(U(w)) are formed over the frequency ranges w, corresponding to the desired resolution around the frequency in question. The ratio of these averages is then formed for the frequency-function estimate, and corresponding expressions define the noise spectrum estimate.

Version History

Introduced before R2006a

expand all

See Also

| | | | | |