Estimate transfer function
the transfer function of a system, using the Welch algorithm and the
To implement the transfer function estimation object:
Define and set up your transfer function estimator object. See Construction.
step to implement
the estimator according to the properties of
The behavior of
step is specific to each object in
Starting in R2016b, instead of using the
tfe = dsp.TransferFunctionEstimator returns
a System object,
tfe, that computes the transfer
function of real or complex signals. This System object uses the
periodogram method and Welch's averaged, modified periodogram
tfe = dsp.TransferFunctionEstimator(' returns
Transfer Function Estimator System object,
with each specified property set to the specified value. You can specify
additional name-value pair arguments in any order as (Name1,Value1,...,NameN,ValueN).
Number of spectral averages
Specify the number of spectral averages as a positive, integer
scalar. The Transfer Function Estimator computes the current estimate
by averaging the last
Source of the FFT length value
Specify the source of the FFT length value as one of
Specify the length of the FFT that the Transfer Function Estimator
uses to compute spectral estimates as a positive, integer scalar.
This property applies when you set the
Specify a window function for the Transfer Function estimator
as one of
Side lobe attenuation of window
Specify the side lobe attenuation of the window as a real, positive
scalar, in decibels (dB). This property applies when you set the
Frequency range of the transfer function estimate
Specify the frequency range of the transfer function estimator
as one of
If you set the
If you set the
Magnitude squared coherence estimate
|getFrequencyVector||Get vector of frequencies at which transfer function is estimated|
|getRBW||Get resolution bandwidth of transfer function|
|reset||Reset internal states of transfer function estimator|
|step||Estimate transfer function of system|
|Common to All System Objects|
Create System object with same property values
Expected number of inputs to a System object
Expected number of outputs of a System object
Check locked states of a System object (logical)
Allow System object property value changes
Note: This example runs only in R2016b or later. If you are using an earlier release, replace each call to the function with the equivalent
step syntax. For example, myObject(x) becomes step(myObject,x).
Generate a sine wave. Use the dsp.TransferFunctionEstimator System object to estimate the system transfer function, and the dsp.ArrayPlot System object to display it.
sin = dsp.SineWave('Frequency',100, 'SampleRate', 1000); sin.SamplesPerFrame = 1000; tfe = dsp.TransferFunctionEstimator('FrequencyRange','centered'); aplot = dsp.ArrayPlot('PlotType','Line','XOffset',-500,'YLimits',... [-120 5],'YLabel','Frequency Response (dB)',... 'XLabel','Frequency (Hz)',... 'Title','System Transfer Function');
Create an FIR Filter System object of order 64 and (normalized) cutoff frequency of 1/4. Add random noise to the sine wave. Step through the System objects to obtain the data streams, and plot the log of the magnitude of the transfer function.
firFilt = dsp.FIRFilter('Numerator',fir1(64,1/4)); for ii = 1:100 x = sin() + 0.05*randn(1000,1); y = firFilt(x); Txy = tfe(x,y); aplot(20*log10(abs(Txy))) end
Given two signals
inputs. We first window the two inputs, and scale them by the window
power. We then take FFT of the signals, calling them
This is followed by calculating
is the square magnitude of the FFT,
X multiplied by the conjugate of
The transfer function estimate is calculated by dividing
For further information refer to the Algorithms section in Spectrum Analyzer, which uses the same algorithm.
The magnitude squared coherence,
is defined as
the power spectral density (PSD) estimates of
respectively. Pxy is the cross power spectral
density (CPSD) estimate of
 Hayes, Monson H. Statistical Digital Signal Processing and Modeling. Hoboken, NJ: John Wiley & Sons, 1996
 Kay, Steven M. Modern Spectral Estimation: Theory and Application. Englewood Cliffs, NJ: Prentice Hall, 1999
 Stoica, Petre and Randolph L. Moses. Spectral Analysis of Signals. Englewood Cliffs, NJ: Prentice Hall, 2005
 Welch, P. D. ``The use of fast Fourier transforms for the estimation of power spectra: A method based on time averaging over short modified periodograms,'' IEEE Transactions on Audio and Electroacoustics, Vol. 15, pp. 70–73, 1967.
Usage notes and limitations:
System Objects in MATLAB Code Generation (MATLAB Coder)
When the FFT length is not a power of two, the executable
generated from this System object relies on prebuilt dynamic library
.dll files) included with MATLAB®. Use
packNGo function to package the code generated
from this object and all the relevant files in a compressed zip file.
Using this zip file, you can relocate, unpack, and rebuild your project
in another development environment where MATLAB is not installed.
For more details, see How To Run a Generated Executable Outside MATLAB.
When the FFT length is a power of two, you can generate standalone C and C++ code from this System object.