Multirate filters are digital filters that change the sample rate of an sampled input signal. The process of rate conversion involves an upsampler, a downsampler, and a lowpass filter to process the signal.
The most basic multirate filters are interpolators, decimators, and noninteger sample rate converters. These filters are building components of more advanced filter technologies such as channelizers, channel synthesizers, two-channel filter banks, and Quadrature Mirror Filter (QMF). You can design these filters in MATLAB® and Simulink® using the designMultirateFIR
function.
The designMultirateFIR
function automatically designs an anti-aliasing FIR filter based on the rate conversion factor that you specify. The inputs to the designMultirateFIR
function are the interpolation factor and the decimation factor. Optionally, you can provide the half-polyphase length or transition width and stopband attenuation. To design a decimator, set the interpolation factor to 1. Similarly, to design an interpolator, set the decimation factor to 1.
To implement the multirate filters in MATLAB, use the coefficients returned by the designMultirateFIR
function as inputs to the dsp.FIRDecimator
, dsp.FIRInterpolator
, and dsp.FIRRateConverter
System objects.
b = designMultirateFIR(1,4); firDecim = dsp.FIRDecimator(4,b)
firDecim = dsp.FIRDecimator with properties: DecimationFactor: 4 NumeratorSource: 'Property' Numerator: [0 -2.2355e-05 -5.0269e-05 -5.2794e-05 0 1.0256e-04 1.9352e-04 … ] Structure: 'Direct form'
Alternatively, you can set the SystemObject
flag of the designMultirateFIR
function to true
. The function designs and automatically creates the appropriate rate conversion object.
firDecim = designMultirateFIR(1,4,'SystemObject',true)
firDecim = dsp.FIRDecimator with properties: DecimationFactor: 4 NumeratorSource: 'Property' Numerator: [0 -2.2355e-05 -5.0269e-05 -5.2794e-05 0 1.0256e-04 1.9352e-04 … ] Structure: 'Direct form'
In Simulink, compute these coefficients using the designMultirateFIR
function in the default Auto mode of the FIR Decimation, FIR Interpolation, and FIR Rate Conversion blocks. You can also specify these coefficients as parameters or pass them through an input port.
These examples show how to implement an FIR decimator in MATLAB and Simulink. You can apply this workflow to an FIR interpolator and FIR rate converter as well.
To implement an FIR Decimator, you must first design it by using the designMultirateFIR
function. Specify the decimation factor of interest (usually greater than 1) and an interpolation factor equal to 1. You can use the default half-polyphase length of 12 and the default stopband attenuation of 80 dB. Alternatively, you can also specify the half-polyphase length, transition width, and stopband attenuation values.
Design an FIR decimator with the decimation factor set to 3 and the half-polyphase length set to 14. Use the default stopband attenuation of 80 dB.
b = designMultirateFIR(1,3,14);
Provide the coefficients vector b
as an input to the dsp.FIRDecimator
System object™.
firDecim = dsp.FIRDecimator(3,b); fvtool(firDecim)
By default, the fvtool
function shows the magnitude response. Navigate through the Filter Visualization Tool toolbar to see the phase response, impulse response, group delay, and other filter analysis information.
Filter a noisy sine wave input using the firDecim
object. The sine wave has frequencies at 1000 Hz and 3000 Hz. The noise is a white Gaussian noise with zero mean and a standard deviation of 1e-5. The decimated output will have one-third the sample rate as the input. Initialize two spectrumAnalyzer
objects, one for the input and the other for the output.
f1 = 1000; f2 = 3000; Fs = 8000; source = dsp.SineWave('Frequency',[f1,f2],'SampleRate',Fs,... 'SamplesPerFrame',1026); specanainput = spectrumAnalyzer('SampleRate',Fs,... 'PlotAsTwoSidedSpectrum',false,... 'Method','welch',... 'ShowLegend',true,'YLimits',[-120 40],... 'Title','Noisy Input signal',... 'ChannelNames', {'Noisy Input'}); specanaoutput = spectrumAnalyzer('SampleRate',Fs/3,... 'PlotAsTwoSidedSpectrum',false,... 'Method','welch',... 'ShowLegend',true,'YLimits',[-120 40],... 'Title','Filtered output',... 'ChannelNames', {'Filtered output'});
Stream the input and filter it in a processing loop.
Note: If you are using R2016a or an earlier release, replace each call to the object with the equivalent step
syntax. For example, obj(x)
becomes step(obj,x)
.
for Iter = 1:1000 input = sum(source(),2); noisyInput = input + (10^-5)*randn(1026,1); output = firDecim(noisyInput); specanainput(noisyInput) specanaoutput(output) end
The input has two peaks: one at 1000 Hz and the other at 3000 Hz. The filter has a lowpass response with a passband frequency of 0.3π rad/sample. With a sample rate of 8000 Hz, that value is a passband frequency of 1200 Hz. The tone at 1000 Hz is unattenuated because it falls in the passband of the filter. The tone at 3000 Hz is filtered out.
Similarly, you can design an FIR interpolator and an FIR rate Converter by providing appropriate inputs to the designMultirateFIR
function. To implement the filters, pass the designed coefficients to the dsp.FIRInterpolator
and dsp.FIRRateConverter
objects.
You can design and implement the FIR multirate filters in Simulink™ using the FIR Decimation, FIR Interpolation, and FIR Rate Conversion blocks.
Open the model 'multiratefiltering.slx'
.
The input signal is a noisy sinusoidal signal with two frequencies: one at 1000 Hz and the other at 3000 Hz. The sample rate of the signal is 8000 Hz and the Samples per frame parameter of the Sine Wave blocks is set to 1026. The noise added to the signal is a white Gaussian noise with zero mean and a variance of 1e-10.
The Coefficient source parameter of the FIR Decimation block is set to Dialog parameters, and the FIR filter coefficients parameter is set to designMultirateFIR(1,2)
. The function uses the default half-polyphase length of 12 and the default stopband attenuation of 80 dB. The magnitude response of the designed filter looks like as follows:
Run the model.
The first spectrum analyzer shows the spectrum of the original signal, while the second spectrum analyzer shows the spectrum of the decimated signal. Because the Rate options parameter in the FIR Decimation block is set to Allow multirate processing
, the frame size of the signal is the same at the input and output of the FIR Decimation block, while the sample rate changes. For more details on this mode, see Rate Conversion by Frame-Rate Adjustment.
Sample rate conversion is a process of converting the sample rate of a signal from one sampling rate to another sampling rate. Multistage filters minimize the amount of computation involved in sample rate conversion. To perform an efficient multistage rate conversion, use the dsp.SampleRateConverter
object that:
Accepts input sample rate and output sample rate as inputs.
Partitions the design problem into optimal stages.
Designs all the filters required by the various stages.
Implements the design.
The design makes sure that aliasing does not occur in the intermediate steps.
In this example, change the sample rate of a noisy sine wave signal from an input rate of 192 kHz to an output rate of 44.1 kHz.
Initialize a sample rate converter object.
SRC = dsp.SampleRateConverter;
Display the filter information.
info(SRC)
ans = 'Overall Interpolation Factor : 147 Overall Decimation Factor : 640 Number of Filters : 3 Multiplications per Input Sample: 27.667188 Number of Coefficients : 8631 Filters: Filter 1: dsp.FIRDecimator - Decimation Factor : 2 Filter 2: dsp.FIRDecimator - Decimation Factor : 2 Filter 3: dsp.FIRRateConverter - Interpolation Factor: 147 - Decimation Factor : 160 '
SRC is a three-stage filter: two FIR decimators followed by an FIR rate converter.
Initialize the sine wave source. The sine wave has two tones: one at 2000 Hz and the other at 5000 Hz.
source = dsp.SineWave ('Frequency',[2000 5000],'SampleRate',192000,... 'SamplesPerFrame',1280);
Initialize two spectrum analyzers, one to see the spectrum of the input signal and the other to see the spectrum of the rate converted output signal. The 'PlotAsTwoSidedSpectrum'
property of the spectrumAnalyzer
objects is set to 'false'
, indicating that the spectrum shown is one-sided in the range [0 Fs/2], where Fs is the sample rate of the signal.
Fsin = SRC.InputSampleRate; Fsout = SRC.OutputSampleRate; specanainput = spectrumAnalyzer('SampleRate',Fsin,... 'PlotAsTwoSidedSpectrum',false,... 'Method','welch',... 'ShowLegend',true,'YLimits',[-120 50],... 'Title','Input signal',... 'ChannelNames', {'Input'}); specanaoutput = spectrumAnalyzer('SampleRate',Fsout,... 'PlotAsTwoSidedSpectrum',false,... 'Method','welch',... 'ShowLegend',true,'YLimits',[-120 50],... 'Title','Rate Converted output',... 'ChannelNames', {'Rate Converted output'});
Stream the input signal and convert the sample rate of the signal using the sample rate converter. View the spectra of both the input and output signals in the two spectrum analyzers.
The spectrum analyzers show the spectrum in the range [0 Fs/2]. For the spectrum analyzer showing the input, Fs/2 is 192000/2. For the spectrum analyzer showing the output, Fs/2 is 44100/2. Hence, the sample rate of the signal changes from 192 kHz to 44.1 kHz.
for Iter = 1:10000 input = sum(source(),2); noisyinput = input + (10^-5)*randn(1280,1); output = SRC(noisyinput); specanainput(noisyinput); specanaoutput(output); end
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