You can estimate the transfer function of an unknown system based on the system's measured input and output data.
In DSP System Toolbox™, you can estimate the transfer function of a system using the dsp.TransferFunctionEstimator
System object™ in MATLAB® and the Discrete Transfer Function Estimator block in Simulink®. The relationship between the input x and output y is modeled by the linear, time-invariant transfer function Txy. The transfer function is the ratio of the cross power spectral density of x and y, Pyx, to the power spectral density of x, Pxx:
Txy(f)=Pyx(f)Pxx(f)
The dsp.TransferFunctionEstimator
object and Discrete Transfer Function Estimator block use the Welch’s averaged periodogram method to compute the Pxx and Pxy. For more details on this method, see Spectral Analysis.
Coherence
The coherence, or magnitude-squared coherence, between x and y is defined as:
Cxy(f)=?Pxy?2Pxx∗Pyy
The coherence function estimates the extent to which you can predict y from x. The value of the coherence is in the range 0 ≤ Cxy(f) ≤ 1. If Cxy = 0, the input x and output y are unrelated. A Cxy value greater than 0 and less than 1 indicates one of the following:
Measurements are noisy.
The system is nonlinear.
Output y is a function of x and other inputs.
The coherence of a linear system represents the fractional part of the output signal power that is produced by the input at that frequency. For a particular frequency, 1 – Cxy is an estimate of the fractional power of the output that the input does not contribute to.
When you set the OutputCoherence
property of dsp.TransferFunctionEstimator
to true
, the object computes the output coherence. In the Discrete Transfer Function Estimator block, to compute the coherence spectrum, select the Output magnitude squared coherence estimate check box.
To estimate the transfer function of a system in MATLAB™, use the dsp.TransferFunctionEstimator
System object™. The object implements the Welch's average modified periodogram method and uses the measured input and output data for estimation.
Initialize the System
The system is a cascade of two filter stages: dsp.LowpassFilter and a parallel connection of dsp.AllpassFilter and dsp.AllpoleFilter.
allpole = dsp.AllpoleFilter; allpass = dsp.AllpassFilter; lpfilter = dsp.LowpassFilter;
Specify Signal Source
The input to the system is a sine wave with a frequency of 100 Hz. The sampling frequency is 44.1 kHz.
sine = dsp.SineWave('Frequency',100,'SampleRate',44100,... 'SamplesPerFrame',1024);
Create Transfer Function Estimator
To estimate the transfer function of the system, create the dsp.TransferFunctionEstimator
System object.
tfe = dsp.TransferFunctionEstimator('FrequencyRange','onesided',... 'OutputCoherence', true);
Create Array Plot
Initialize two dsp.ArrayPlot
objects: one to display the magnitude response of the system and the other to display the coherence estimate between the input and the output.
tfeplotter = dsp.ArrayPlot('PlotType','Line',... 'XLabel','Frequency (Hz)',... 'YLabel','Magnitude Response (dB)',... 'YLimits',[-120 20],... 'XOffset',0,... 'XLabel','Frequency (Hz)',... 'Title','System Transfer Function',... 'SampleIncrement',44100/1024); coherenceplotter = dsp.ArrayPlot('PlotType','Line',... 'YLimits',[0 1.2],... 'YLabel','Coherence',... 'XOffset',0,... 'XLabel','Frequency (Hz)',... 'Title','Coherence Estimate',... 'SampleIncrement',44100/1024);
By default, the x-axis of the array plot is in samples. To convert this axis into frequency, set the 'SampleIncrement' property of the dsp.ArrayPlot
object to Fs/1024. In this example, this value is 44100/1024, or 43.0664. For a two-sided spectrum, the XOffset
property of the dsp.ArrayPlot
object must be [-Fs/2]. The frequency varies in the range [-Fs/2 Fs/2]. In this example, the array plot shows a one-sided spectrum. Hence, set the XOffset
to 0. The frequency varies in the range [0 Fs/2].
Estimate the Transfer Function
The transfer function estimator accepts two signals: input to the two-stage filter and output of the two-stage filter. The input to the filter is a sine wave containing additive white Gaussian noise. The noise has a mean of zero and a standard deviation of 0.1. The estimator estimates the transfer function of the two-stage filter. The output of the estimator is the frequency response of the filter, which is complex. To extract the magnitude portion of this complex estimate, use the abs function. To convert the result into dB, apply a conversion factor of 20*log10(magnitude).
for Iter = 1:1000 input = sine() + .1*randn(1024,1); lpfout = lpfilter(input); allpoleout = allpole(lpfout); allpassout = allpass(lpfout); output = allpoleout + allpassout; [tfeoutput,outputcoh] = tfe(input,output); tfeplotter(20*log10(abs(tfeoutput))); coherenceplotter(outputcoh); end
The first plot shows the magnitude response of the system. The second plot shows the coherence estimate between the input and output of the system. Coherence in the plot varies in the range [0 1] as expected.
Magnitude Response of the Filter Using fvtool
The filter is a cascade of two filter stages - dsp.LowpassFilter and a parallel connection of dsp.AllpassFilter and dsp.AllpoleFilter. All the filter objects are used in their default state. Using the filter coefficients, derive the system transfer function and plot the frequency response using freqz. Below are the coefficients in the [Num] [Den] format:
All pole filter - [1 0] [1 0.1]
All pass filter - [0.5 -1/sqrt(2) 1] [1 -1/sqrt(2) 0.5]
Lowpass filter - Determine the coefficients using the following commands:
lpf = dsp.LowpassFilter; Coefficients = coeffs(lpf);
Coefficients.Numerator gives the coefficients in an array format. The mathematical derivation of the overall system transfer function is not shown here. Once you derive the transfer function, run fvtool and you can see the frequency response below:
The magnitude response that fvtool shows matches the magnitude response that the dsp.TransferFunctionEstimator
object estimates.
To estimate the transfer function of a system in Simulink, use the Discrete Transfer Function Estimator block. The block implements the Welch's average modified periodogram method and uses the measured input and output data for estimation.
The system is a cascade of two filter stages: a lowpass filter and a parallel connection of an allpole filter and allpass filter. The input to the system is a sine wave containing additive white Gaussian noise. The noise has a mean of zero and a standard deviation of 0.1. The input to the estimator is the system input and the system output. The output of the estimator is the frequency response of the system, which is complex. To extract the magnitude portion of this complex estimate, use the Abs block. To convert the result into dB, the system uses a dB (1 ohm) block.
Open and Inspect the Model
To open the model, enter ex_transfer_function_estimator
in the MATLAB command prompt.
Here are the settings of the blocks in the model.
Block | Parameter Changes | Purpose of the block |
---|---|---|
Sine Wave |
|
Sinusoid signal with frequency at 100 Hz |
Random Source |
|
Random Source block generates a random noise signal with properties specified through the block dialog box |
Lowpass Filter | No change | Lowpass filter |
Allpole Filter | No change | Allpole filter with coefficients [1 0.1] |
Discrete Filter |
|
Allpass filter with coefficients [-1/sqrt(2) 0.5] |
Discrete Transfer Function Estimator |
|
Transfer function estimator |
Abs | No change | Extracts the magnitude information from the output of the transfer function estimator |
First Array Plot block |
Click View:
|
Shows the magnitude response of the system |
Second Array Plot block |
Click View:
|
Shows the coherence estimate |
By default, the x-axis of the array plot is in samples. To convert this axis into frequency, the Sample increment parameter is set to Fs/1024
. In this example, this value is 44100/1024
, or 43.0664
. For a two-sided spectrum, the X-offset parameter must be –Fs/2
. The frequency varies in the range [-Fs/2 Fs/2]
. In this example, the array plot shows a one-sided spectrum. Hence, the X-offset is set to 0. The frequency varies in the range [0 Fs/2]
.
Run the Model
The first plot shows the magnitude response of the system. The second plot shows the coherence estimate between the input and output of the system. Coherence in the plot varies in the range [0 1]
as expected.
Matlabsolutions.com provides guaranteed satisfaction with a
commitment to complete the work within time. Combined with our meticulous work ethics and extensive domain
experience, We are the ideal partner for all your homework/assignment needs. We pledge to provide 24*7 support
to dissolve all your academic doubts. We are composed of 300+ esteemed Matlab and other experts who have been
empanelled after extensive research and quality check.
Matlabsolutions.com provides undivided attention to each Matlab
assignment order with a methodical approach to solution. Our network span is not restricted to US, UK and Australia rather extends to countries like Singapore, Canada and UAE. Our Matlab assignment help services
include Image Processing Assignments, Electrical Engineering Assignments, Matlab homework help, Matlab Research Paper help, Matlab Simulink help. Get your work
done at the best price in industry.
Desktop Basics - MATLAB & Simulink
Array Indexing - MATLAB & Simulink
Workspace Variables - MATLAB & Simulink
Text and Characters - MATLAB & Simulink
Calling Functions - MATLAB & Simulink
2-D and 3-D Plots - MATLAB & Simulink
Programming and Scripts - MATLAB & Simulink
Help and Documentation - MATLAB & Simulink
Creating, Concatenating, and Expanding Matrices - MATLAB & Simulink
Removing Rows or Columns from a Matrix
Reshaping and Rearranging Arrays
Add Title and Axis Labels to Chart
Change Color Scheme Using a Colormap
How Surface Plot Data Relates to a Colormap
How Image Data Relates to a Colormap
Time-Domain Response Data and Plots
Time-Domain Responses of Discrete-Time Model
Time-Domain Responses of MIMO Model
Time-Domain Responses of Multiple Models
Introduction: PID Controller Design
Introduction: Root Locus Controller Design
Introduction: Frequency Domain Methods for Controller Design
DC Motor Speed: PID Controller Design
DC Motor Position: PID Controller Design
Cruise Control: PID Controller Design
Suspension: Root Locus Controller Design
Aircraft Pitch: Root Locus Controller Design
Inverted Pendulum: Root Locus Controller Design
Get Started with Deep Network Designer
Create Simple Image Classification Network Using Deep Network Designer
Build Networks with Deep Network Designer
Classify Image Using GoogLeNet
Classify Webcam Images Using Deep Learning
Transfer Learning with Deep Network Designer
Train Deep Learning Network to Classify New Images
Deep Learning Processor Customization and IP Generation
Prototype Deep Learning Networks on FPGA
Deep Learning Processor Architecture
Deep Learning INT8 Quantization
Quantization of Deep Neural Networks
Custom Processor Configuration Workflow
Estimate Performance of Deep Learning Network by Using Custom Processor Configuration
Preprocess Images for Deep Learning
Preprocess Volumes for Deep Learning
Transfer Learning Using AlexNet
Time Series Forecasting Using Deep Learning
Create Simple Sequence Classification Network Using Deep Network Designer
Train Classification Models in Classification Learner App
Train Regression Models in Regression Learner App
Explore the Random Number Generation UI
Logistic regression create generalized linear regression model - MATLAB fitglm 2
Support Vector Machines for Binary Classification
Support Vector Machines for Binary Classification 2
Support Vector Machines for Binary Classification 3
Support Vector Machines for Binary Classification 4
Support Vector Machines for Binary Classification 5
Assess Neural Network Classifier Performance
Discriminant Analysis Classification
Train Generalized Additive Model for Binary Classification
Train Generalized Additive Model for Binary Classification 2
Classification Using Nearest Neighbors
Classification Using Nearest Neighbors 2
Classification Using Nearest Neighbors 3
Classification Using Nearest Neighbors 4
Classification Using Nearest Neighbors 5
Gaussian Process Regression Models
Gaussian Process Regression Models 2
Understanding Support Vector Machine Regression
Extract Voices from Music Signal
Align Signals with Different Start Times
Find a Signal in a Measurement
Extract Features of a Clock Signal
Filtering Data With Signal Processing Toolbox Software
Find Periodicity Using Frequency Analysis
Find and Track Ridges Using Reassigned Spectrogram
Classify ECG Signals Using Long Short-Term Memory Networks
Waveform Segmentation Using Deep Learning
Label Signal Attributes, Regions of Interest, and Points
Introduction to Streaming Signal Processing in MATLAB
Filter Frames of a Noisy Sine Wave Signal in MATLAB
Filter Frames of a Noisy Sine Wave Signal in Simulink
Lowpass Filter Design in MATLAB
Tunable Lowpass Filtering of Noisy Input in Simulink
Signal Processing Acceleration Through Code Generation
Signal Visualization and Measurements in MATLAB
Estimate the Power Spectrum in MATLAB
Design of Decimators and Interpolators
Multirate Filtering in MATLAB and Simulink