MATLAB DSP Programs: Raja Rajasakeran Venkat Peddigari Pete Bernardin
MATLAB DSP Programs: Raja Rajasakeran Venkat Peddigari Pete Bernardin
Raja Rajasakeran
Venkat Peddigari
Pete Bernardin
Bandpass Filter
close all;
clear all;
r1 = 0.9;
r2 = 0.88;
r3=0.9;
theta1 = pi/5;
theta2 = 3*pi/10;
theta3=4*pi/10;
p1 = r1*cos(theta1) + i*r1*sin(theta1);
p2 = r1*cos(theta2) + i*r2*sin(theta2);
p3 = r3*cos(theta3) + i*r3*sin(theta3);
p2 = r2*cos(theta2) + i*r2*sin(theta2);
!aroots = [p1,conj(p1),p2,conj(p2), p3, conj(p3)];
aroots = [p2,conj(p2), p3, conj(p3)];
a = poly(aroots);
b = [1 zeros(1,18) -1];
b1 = [1];
[h,w] = freqz(b1,a);
H ( z ) 1 / 0.9 1 e j 2 z 1 1 e j 2 z 1 0.9 1 e j3 z 1 1 e j3 z 1
freqzplot(h,w, 'mag');
figure;
1 / 0.9 1 2 cos 2 z 1 z 2
0.9 1 2 cos 3 z 1 z 2
2 0.3
3 0.4
freqzplot(h,w,'squared');
100% Duty
50% Duty
12.5% Duty
Notch Filters
clear all;
close all;
a = [1 -1.2726 0.81];
b = [1 -1.414 1];
[H, W] = freqz(b,a);
figure;
freqzplot(H,W,'linear');
title ('Pole-zero Notch Filter - Mag');
figure;
freqzplot(H,W);
title ('Pole-zero Notch Filter - dB');
a1 = [1];
b1 = [1 -1.414 1];
[H1, W] = freqz(b1,a1);
figure;
freqzplot(H1,W,'linear');
title ('All zero Notch Filter - Mag');
figure;
freqzplot(H1,W);
title ('All zero Notch Filter - dB');
Resonators
clear all;
close all;
r = 0.99;
theta = pi/4;
a = [1 -2*r*theta r^2];
b = 1;
[H, W] = freqz(b,a);
figure;
freqzplot(H,W,'linear');
title ('Resonator r=0.99, theta = pi/4 - Mag');
figure;
freqzplot(H,W);
title (' Resonator r=0.99, theta = pi/4- dB');
r = 0.95;
theta = pi/4;
a = [1 -2*r*theta r^2];
b = 1;
[H, W] = freqz(b,a);
figure;
freqzplot(H,W,'linear');
title ('Resonator r=0.95, theta = pi/4 - Mag');
figure;
freqzplot(H,W);
title (' Resonator r=0.95, theta = pi/4- dB');
r = 0.99;
theta = pi/4;
a = [1 -2*r*theta r^2];
b = [1 0 -1]
[H, W] = freqz(b,a);
figure;
freqzplot(H,W,'linear');
Resonators (continued)
2
10
Comb Filters
clear all;
close all;
a = [1 -1];
b = [1 0 0 0 0 0 0 0 0 0 0 -1];
b = b/11;
[H, W] = freqz(b,a);
figure;
freqzplot(H,W,'linear');
title ('Comb Filter M=10 - Mag');
figure;
freqzplot(H,W);
title ('Comb Filter M=10 - dB');
bz = zeros (1,54);
a1 = [1 0 0 0 0 -1];
b1 = [1 [bz] -1];
[H, W] = freqz(b1,a1);
figure;
freqzplot(H,W,'linear');
title ('LM Comb Filter L = 5 M=10 - Mag');
figure;
freqzplot(H,W);
title ('LM Comb Filter L = 5 M=10 - dB');
Time
% 16 overlapping sections
NFFT = 512;
Noverlap = 256
figure;
pwelch(y, 512, Noverlap, NFFT, FS)
% 32 overlapping sections
NFFT = 256;
Noverlap = 128
figure;
pwelch(y, 256, Noverlap, NFFT, FS)
Hz Res
2 Hz Res
4 Hz Res