Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Design a two-stage decimator for the following specifications: Decimation factor

ID: 3802798 • Letter: D

Question

Design a two-stage decimator for the following specifications: Decimation factor: D = 100 Passband: 0 lessthanorequalto F lessthanorequalto 60 Hz Transition band: 60 lessthanorequalto F lessthanorequalto 65 Hz Passband ripple: dergree_1 = 10^-1 Stopband attenuation: delta_2 = 10^-3 Sampling frequency: F_sampling = 5 X 10^4 Hz Use MATLAB to plot |H_0(omega)|, |H_1(w)| and |tf(omega)| Where H_0(omega)) denotes the frequency response of the filter in stage H_1(omega) denotes the frequency response of the filter in stage 2 H(omega) denotes the frequency response of the equivalent filter if the system is a single-stage decimator.

Explanation / Answer

clear all, close all
% STEP 1-a),g)
% Lowpass FIR filter design
M = 100; % Decimation factor
L = 4; % Interpolation factor
ap = 0; as = 60; % Specifying passband/stopband ripples
Fp = 0.1; Fs = 1/M; % Specifying passband/stopband boundary frequencies for Case b tolerance scheme
dev = [(10^(-1)), 10^(-3)]; % Passband and stopband ripples
F = [Fp Fs]; % Boundary frequencies
A = [1 0]; % Desired amplitudes
[Nord,Fo,Ao,W] = firpmord(F,A,dev); % Estimating the filter order
Nord = Nord+2; % Increasing the Nord by 2 to provide some margin for Case b tolerance scheme
h = firpm(Nord,Fo,Ao,W); % Computing the filter coefficients
[H,F1] = freqz(h,1,1024,50000); % Computation of filter frequency response
figure (1)
subplot(4,1,1), plot(F1,20*log10(abs(H))), title('Figure 1: Spectra (commutative structure)'), legend(-1,' Filter magn. resp.')
ylabel('Gain, dB'), axis([0,6000,-80,5])

% STEP 2-b),g)
Fx = 12000;
% Generating the input signal x
n = 0:1000; % Time index
ff = [0,0.1,0.5,0.6,0.8,1]; a = [0,0,0.05,0.9,0,0];
x = fir2(1000,ff,a);
x = 400*x+cos(2*pi*Fp/2*n)+cos(2*pi*3*Fp/4*n)+randn(size(n)); z=x;
[X,F1] = freqz(x,1,1024,12000); % Computing the signal spectrum
subplot(4,1,2), plot(F1,abs(X)), legend(-1,'Spectr. input sign.'), ylabel('|X(F)|'), axis([0,6000,0,500])
Fy=Fx/M;

% STEP 3-c)
% Polyphase decomposition
E = reshape(h,4,length(h)/4);

% STEP 4-d),g)
% Polyphase downsampling and filtering
x0 = x(1:4:length(x)); x1 = [0,x(4:4:length(x))]; x2 = [0,x(3:4:length(x))];
x3 = [0,x(2:4:length(x))];
y0 = filter(E(1,:),1,x0); y1 = filter(E(2,:),1,x1); y2 = filter(E(3,:),1,x2); y3=filter(E(4,:),1,x3);
ydec = y0 + y1 + y2 + y3; % Decimated signal
[Ydec,F2] = freqz(ydec,1,512,3000);
subplot(4,1,3), plot(F2,abs(Ydec)), legend(-1,'Spectr. dec. sign.'), ylabel('|Y_d_e_c(F)|'), axis([0,1500,0,150])

% STEP 5-e),g)
x = ydec; % Input to the interpolator
% Poliphase filtering and up-sampling
u0 = L*filter(E(1,:),1,x); u1 = L*filter(E(2,:),1,x); u2 = L*filter(E(3,:),1,x);
u3 = L*filter(E(4,:),1,x);
U = [u0;u1;u2;u3];
yint = U(:); % Interpolated signal
[Yint,F3] = freqz(yint,1,1024,12000);
subplot(4,1,4), plot(F3,abs(Yint)); legend(-1,' Spectr. int. sign.'), xlabel('Frequency, Hz')
ylabel('|Y_i_n_t(F)|'), axis([0,6000,0,500])

% STEP 6-h)
% Computing the multiplication rate in decimator and in interpolator
Rm_dec=(Nord+1)*Fx/M;
Rm_int=(Nord+1)*Fx/L;
disp('Multiplication rates of commutative structures')
disp(['Decimator (mult./second): ', num2str(Rm_dec)]);
disp(['Interpolator (mult./second): ', num2str(Rm_int)]);
% STEP 7-h)
xf = filter(h,1,z);
xds = downsample(xf,M);
yus = upsample(xds,L);
yf = filter(L*h,1,yus);

figure (2)
subplot(4,1,1), plot(F1,20*log10(abs(H))), title('Figure 2: Spectra (cascade structure)'), legend(-1,' Filter magn. resp.'),
ylabel('Gain, dB'), axis([0,6000,-80,5])
subplot(4,1,2), plot(F1,abs(X)), legend(-1,'Spectr. input sign.'), ylabel('|X(F)|'), axis([0,6000,0,500])
[Xds,Fds] = freqz(xds,1,512,3000);
subplot(4,1,3), plot(Fds,abs(Xds)), legend(-1,'Spectr. dec. sign.'), ylabel('|X_d_s(F)|'), axis([0,1500,0,150])
[Yf,Fus] = freqz(yf,1,1024,12000);
subplot(4,1,4), plot(Fus,abs(Yf)); legend(-1,' Spectr. int. sign.'), xlabel('Frequency, Hz')
ylabel('|Y_f(F)|'), axis([0,6000,0,500])

% Comparing Figures 1 and 2, we conclude that commutative structure consisting of 4 polyphase subfilters in parallel is successfully verified.
% Both figures display the identical results.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote