![]() |
![]() |
|
|
| <<Home | Lab 11 (Multirate DSP) | |||
|
MATLAB has a number of built-in functions for sampling rate conversion and multirate processing, Some of these include following.
Decimating the signal Example 1 A discrete time signal is given by y = sin(0.1л n) Decimate the signal by a factor of 2 and 4. Plot the original and decimated signals. Use the decimate function. Solution n=0:1:100; y=sin(0.1*pi*n); y1=decimate(y,2); y2=decimate(y,4); subplot(311) stem(y(1:length(y))) ylabel( 'Orignal Signal')grid subplot(312) stem(y1(1:length(y1))) ylabel( 'decimated by 2')grid subplot(313) stem(y2(1:length(y2))) xlabel( 'Tiem')ylabel( 'Decimated by 4')grid Result
Decimating the signal using resample
Example 2 Repeat the above example with resample function Solution n=0:1:100; y=sin(0.1*pi*n); y1=resample(y,1,2); y2=resample(y,1,4); subplot(311) stem(y(1:length(y))) ylabel( 'Orignal Signal')grid subplot(312) stem(y1(1:length(y1))) ylabel( 'Decimated by 2')grid subplot(313) stem(y2(1:length(y2))) xlabel( 'Time')ylabel( 'Decimated by 4')grid Result
Interpolating the signal
Example 3 Consider the signal of example 1. Interpolate the signal by a factor of 2 and 4 using interp function. Solution n=0:1:100; y=sin(0.1*pi*n); y1=interp(y,2); y2=interp(y,4); subplot(311) stem(y(1:length(y))) ylabel( 'Orignal Signal')grid subplot(312) stem(y1(1:length(y1))) ylabel( 'Interpolted by 2')grid subplot(313) stem(y2(1:length(y2))) xlabel( 'Time')ylabel( 'Interpolated by 4')grid Result
Interpolating the signal
Exercise 1 Repeat example 3 using resample function. Solution n=0:1:100; y=sin(0.1*pi*n); y1=resample(y,2,1); y2=resample(y,4,1); subplot(311) stem(y(1:length(y))) ylabel( 'Orignal Signal')grid subplot(312) stem(y1(1:length(y1))) ylabel( 'Interpolted by 2')grid subplot(313) stem(y2(1:length(y2))) xlabel( 'Time')ylabel( 'Interpollted by 4')grid Result
Decimating & Interpolating the signal
Exercise 2 and 3 Repeat example 2 to decimate the signal by a factor of 2/3 Repeat example 2 to interpolate the signal by a factor of 5/2 Solution n=0:1:100; y=sin(0.1*pi*n); y1=resample(y,2,3); y2=resample(y,5,2); subplot(311) stem(y(1:length(y))) ylabel( 'Orignal Signal')grid subplot(312) stem(y1(1:length(y1))) ylabel( 'Decimated by 2/3')grid subplot(313) stem(y2(1:length(y2))) xlabel( 'Time')ylabel( 'Interpollted by 5/2')grid Result
Decimating & Interpolating the signal
Exercise 4 A continuous time signal is characterized by the following function. x(t) = Acos(2лf1t) + Bcos (2лf2t) a) Generate, with the aid of MATLAB, a discrete time equivalent of the signal. Assume a sampling frequency of 1 kHz, f1 = 50 kHz, f2 = 100 kHz, A=1.5 and B = 1. b) Interpolate the discrete time signal by a factor of 4 using interp command. c) Determine the output of the interpolator in step (b) by a factor of 4 using the decimate function d) Plot the original, interpolated and decimated discrete time signals. Solution t=0:1:100; a=1.5; b=1; fs=1000; ts=1/fs; f1= 50; f2=100; y=a*cos(2*pi*f1/fs*t) + b*cos(2*pi*f2/fs*t); y1=interp(y,4); y2=decimate(y1,4); subplot(311) stem(y(1:length(y))) ylabel( 'Orignal Signal')grid subplot(312) stem(y1(1:length(y1))) ylabel( 'Interpolated by 4')grid subplot(313) stem(y2(1:length(y2))) xlabel( 'Time')ylabel( 'Decimated by 4')grid Result
Decimating & Interpolating the signal
Exercise 5 Repeat exercise "4" using resample function Solution t=0:1:100; a=1.5; b=1; fs=1000; ts=1/fs; f1= 50; f2=100; y=a*cos(2*pi*f1/fs*t) + b*cos(2*pi*f2/fs*t); y1=resample(y,4,1); y2=resample(y1,1,4); subplot(311) stem(y(1:length(y))) ylabel( 'Orignal Signal')grid subplot(312) stem(y1(1:length(y1))) ylabel( 'Interpolated by 4')grid subplot(313) stem(y2(1:length(y2))) xlabel( 'Time')ylabel( 'Decimated by 4')grid Result
HELP DECIMATE
DECIMATE Resample data at a lower rate
after lowpass filtering. INTERP
INTERP Resample data at a higher rate using
lowpass interpolation. RESAMPLE
RESAMPLE Change the sampling rate of a
signal. DSP Lab 1 DSP Lab2 DSP Lab 3 DSP Lab4 DSP Lab 5 DSP Lab 6 DSP Lab7 DSP Lab8 DSP Lab9 DSP Lab10 DSP Lab 11 Other material |
||||
| <<Home | ||||
|
||||||