Professional Documents
Culture Documents
Nitish S. Prabhu
1MS10EC071
Table of contents
Analysis of system form it i/o equations .................................................................................................. 1
Impulse response ...................................................................................................................................... 2
Sampling theorem..................................................................................................................................... 3
FIR filter - window method ....................................................................................................................... 5
IIR Low pass filters .................................................................................................................................... 9
IIR Filter - using bilenear transformation .............................................................................................. 112
% Feedforward coefficients
a=1;
% Feedback coefficients
n=100;
% Plot the Pole-Zero diagram (Fig 1.a)
subplot(4,1,1);
zplane(b,a);
% Plot the frequency response (Fig 1.b)
subplot(4,1,2);
[h,w]=freqz(b,a,n);
plot(h);
% Plot the phase response (Fig 1.c)
subplot(4,1,3);
phase=angle(h);plot(phase);
Impulse response
To determine the impulse response of a given system and thus model the behavior of the system
clc
clear all
close all
n=-20:100;
b=1;
% Coefficients
% Impulse function
stem(n,x);
title('Filter Output');
figure
y=filter(b,a,x);
stem(n,y)
title('Unit Impulse function');
Sampling theorem
The setup below explains the requirement of fast sampling rates greater than that of Nyquest rates. The
behavior of a system to sampling rates equal to and greater than that of Nyquest frequency is tested.
clc
close all
clear all
f1= 500;
f2= 2000;
% Define the parameters of the signal
N=256;
n=0:N-1;
fs=2*max(f1,f2);
% Case1: Nyquist rate sampling with 'a' and 'b' as input signals
a=sin(2*pi*(f1)*n);
b=sin(2*pi*(f2)*n);
x=sin(2*pi*(f1/fs)*n)+sin(2*pi*(f2/fs)*n);
nt=n./fs;
% Plot of the sine wave to be sampled
subplot(2,2,1)
plot(nt,x)
xlabel('Time(s)')
ylabel('Amplitude')
title('Sampling at nyquist rate')
grid;
X=fft(x);
mag=abs(X);
fhz=n.*(fs/N);
% The frequecy domain representation
subplot(2,2,3)
plot(fhz(1:N/2),mag(1:N/2));
xlabel('Frequency')
ylabel('Amplitude')
title('Sinewave in freq domain')
grid
% Max frequency
FN = FS/2;
% Nyquest frequency
fp = 1500;
% Passband frequency
tw = 500;
% Transition Width
fs = fp + tw;
fc = (fp+fs)/2/FN;
tw = (fs - fp)/FS;
A = 5;
for A = 15:15:60
if A<=21
N = ceil(2/tw);
wn = boxcar(N);
str = 'Rect wind';
elseif A>21 && A<=44
N = ceil(4/tw);
wn = hanning(N);
str = 'Hanning';
elseif A>44 && A<=53
N = ceil(4/tw);
wn = hamming(N);
str = 'Hamming';
else
N = ceil(4/tw);
wn = blackman(N);
str = 'Blackman';
end
disp(str);
hd = fir1( N-1, fc, boxcar(N));
hn = fir1( N-1,fc, wn);
disp('FIR coefficients');
disp(hn);
[H,f]= freqz(hn,1,512,FS);
mag=(20*log10(abs(H)));
figure,plot(f,mag), grid on
xlabel ('Freq(Hz)');
ylabel('Mag resp(dB)');
title(strcat(str,' Window'));
end
Rectangular window :
FIR coefficients
Columns 1 through 7
0.0126
0.0188
-0.0066
-0.0246
-0.0026
0.0281
0.0153
0.0224
0.0537
-0.0067
-0.0878
-0.0358
0.3916
0.1815
-0.0358
-0.0878
-0.0067
-0.0318
-0.0281
0.0153
0.0281
-0.0026
Columns 8 through 14
-0.0281
-0.0318
Columns 15 through 21
0.1815
0.3916
Columns 22 through 28
0.0537
0.0224
Columns 29 through 32
-0.0246
-0.0066
0.0188
0.0126
8.8826
0.0133
8.8826
1.0e+05 *
0.0000
-1.0308
0.3530
%Filter order
fs=1280;
%Sampling frequency
fc=150;
wc=2*pi*fc;
%Analog filter design -- Normalised Butterworth filter
[b,a]=butter(N,1,'s');
[z,p,k]=butter(N,1,'s');
%Prewarping
%2*Fs=1, Fs=0.5
-1.0048
0.3561