You are on page 1of 14

qwertyuiopasdfghjklzxcvbnmqwertyui

opasdfghjklzxcvbnmqwertyuiopasdfgh
jklzxcvbnmqwertyuiopasdfghjklzxcvb
nmqwertyuiopasdfghjklzxcvbnmqwer
M.Bilal Junaid
tyuiopasdfghjklzxcvbnmqwertyuiopas
Assignment :4
dfghjklzxcvbnmqwertyuiopasdfghjklzx
cvbnmqwertyuiopasdfghjklzxcvbnmq
wertyuiopasdfghjklzxcvbnmqwertyuio
pasdfghjklzxcvbnmqwertyuiopasdfghj
klzxcvbnmqwertyuiopasdfghjklzxcvbn
mqwertyuiopasdfghjklzxcvbnmqwerty
uiopasdfghjklzxcvbnmqwertyuiopasdf
ghjklzxcvbnmqwertyuiopasdfghjklzxc
vbnmqwertyuiopasdfghjklzxcvbnmrty
uiopasdfghjklzxcvbnmqwertyuiopasdf
ghjklzxcvbnmqwertyuiopasdfghjklzxc
MS(EE)-SP014-014

Advance Digital Signal Processing

Answer 1
close all
clear all

%FIR Kaiser window Filter....................................................................


%Wc=(Fpass+Fstop)/2... which is .25pi in our case
Fpass = 0.2;
% Passband Frequency
Fstop = 0.3;
% Stopband Frequency
Dpass = 0.057501127785; % Passband Ripple
Dstop = 0.0001;
% Stopband Attenuation
flag = 'noscale';
% Sampling Flag
% Calculate the order from the parameters using KAISERORD.
[N,Wn,BETA,TYPE] = kaiserord([Fpass Fstop], [1 0], [Dstop Dpass]);
% Calculate the coefficients using the FIR1 function.
[b a] = fir1(N, Wn, TYPE, kaiser(N+1, BETA), flag);
Hd = dfilt.dffir(b);
figure
Freqz(b,a)
title('Magnitude and phase of FIR Kaiser window filter ');
%Group delay computation
[Gd,w] = grpdelay(b,a,256);
figure;
plot(w,Gd); %Zoom in the plot to see the range from 0 to wp
xlabel(' 0 <= w <= wp ');
ylabel('Grp(H(ejw))');
title('Group Delay of FIR Kaiser Window Filter');
%....................................................................

%IIR Chebsev filter


%Filter....................................................................

N = 10; % Order
Wp = 0.25; % Passband Frequency
Apass = .2; % Passband Ripple (dB)
% Construct an FDESIGN object and call its CHEBY1 method.
[b1,a1] = cheby1(N,Apass,Wp,'low')
figure
freqz(b1,a1)
title('Magnitude and phase of IIR Chebsev filter ');
[Gd,w] = grpdelay(b1,a1,256);
figure;
plot(w,Gd); %Zoom in the plot to see the range from 0 to wp
xlabel(' 0 <= w <= wp ');
ylabel('Grp(H(ejw))');
title('Group Delay of IIR Chebsev filter ');

....................................................................

Answer 2
close all;
clear all;
%narrow band
%signals...................................................................
%..
k = [0:199]
x1 = cos(0.2*pi*k).*hanning(200)'; %narrow band signal..with wc=.2pi
x1(1:49)=0
x1(151:200)=0
figure;
plot(k,x1);
xlabel('k');
ylabel('x1');
title('narrow band signal x1');
x2 = cos(0.4*pi*k).*hanning(200)'; %narrow band signal with twice frequency and sample created at differnet points with wc=.4pi
x2(1:74)=0
x2(176:200)=0
figure;
plot(k,x2);
xlabel('k');
ylabel('x2');
title('narrow band signal x2');
%..................................................................
%FIR Kaiser window Filter....................................................................
%Wc=(Fpass+Fstop)/2... which is .25pi in our case
Fpass = 0.2;
% Passband Frequency
Fstop = 0.3;
% Stopband Frequency
Dpass = 0.057501127785; % Passband Ripple
Dstop = 0.0001;
% Stopband Attenuation
flag = 'noscale';
% Sampling Flag
% Calculate the order from the parameters using KAISERORD.
[N,Wn,BETA,TYPE] = kaiserord([Fpass Fstop], [1 0], [Dstop Dpass]);
% Calculate the coefficients using the FIR1 function.
[b a] = fir1(N, Wn, TYPE, kaiser(N+1, BETA), flag);
Hd = dfilt.dffir(b);
figure
Freqz(b,a)
title('Magnitude and phase of FIR Kaiser window filter ');
%Group delay computation
[Gd,w] = grpdelay(b,a,256);
figure;
plot(w,Gd); %Zoom in the plot to see the range from 0 to wp
xlabel(' 0 <= w <= wp ');
ylabel('Grp(H(ejw))');
title('Group Delay of FIR Kaiser Window Filter');
%....................................................................

%IIR Chebsev filter


%Filter....................................................................

N = 10; % Order
Wp = 0.25; % Passband Frequency
Apass = .2; % Passband Ripple (dB)

% Construct an FDESIGN object and call its CHEBY1 method.


[b1,a1] = cheby1(N,Apass,Wp,'low')
figure
freqz(b1,a1)
title('Magnitude and phase of IIR Chebsev filter ');
[Gd,w] = grpdelay(b1,a1,256);
figure;
plot(w,Gd); %Zoom in the plot to see the range from 0 to wp
xlabel(' 0 <= w <= wp ');
ylabel('Grp(H(ejw))');
title('Group Delay of IIR Chebsev filter ');

%....................................................................

%%Filtering the output...............................................


%Filter using kaiser Window
y1=filter(b,a,x1) % filtering first narrow band singal x1
figure
plot(y1)
title('Filtered x1 using Kaisar window filter ');

y2=filter(b,a,x2) % filtering second narrow band singal x2


figure
plot(y2)
title('Filtered x2 using Kaisar window filter ');
%...............................................................
%Filter using IIR chebsev
z1=filter(b1,a1,x1) % filtering first narrow band singal x1
figure
plot(z1)
title('Filtered x1 using IIR chebsev filter ');

z2=filter(b1,a1,x2) % filtering second narrow band singal x2


figure
plot(z2)
title('Filtered x2 using IIR chebsev filter ');
%...............................................................
%Group delay in FIR filter is higher as filterd output of it is more
%shifted compared to IIR filter

%...................................................................

%Group delay in FIR filter is higher as filtered output of it is more shifted


compared to IIR filter also because IIR filter has ORDER compared to FIR.

Answer 3
%Creating wideband signal by passing via VCO>.. similar way FM is modulated
%by VCO to get wideband signal
fs = 10;
t = 0:1/fs:20
x = vco(sawtooth(2*pi*t,0.9),4,fs);
x(20:200)=0;
plot(t,x)
figure
specgram(x)
%..................................................................
%FIR Kaiser window Filter....................................................................
%Wc=(Fpass+Fstop)/2... which is .25pi in our case
Fpass = 0.2;
% Passband Frequency
Fstop = 0.3;
% Stopband Frequency
Dpass = 0.057501127785; % Passband Ripple
Dstop = 0.0001;
% Stopband Attenuation
flag = 'noscale';
% Sampling Flag
% Calculate the order from the parameters using KAISERORD.
[N,Wn,BETA,TYPE] = kaiserord([Fpass Fstop], [1 0], [Dstop Dpass]);
% Calculate the coefficients using the FIR1 function.
[b a] = fir1(N, Wn, TYPE, kaiser(N+1, BETA), flag);
Hd = dfilt.dffir(b);
figure
Freqz(b,a)
title('Magnitude and phase of FIR Kaiser window filter ');
%Group delay computation
[Gd,w] = grpdelay(b,a,256);
figure;
plot(w,Gd); %Zoom in the plot to see the range from 0 to wp
xlabel(' 0 <= w <= wp ');
ylabel('Grp(H(ejw))');
title('Group Delay of FIR Kaiser Window Filter');
%....................................................................

%IIR Chebsev filter


%Filter....................................................................

N = 10; % Order
Wp = 0.25; % Passband Frequency
Apass = .2; % Passband Ripple (dB)
% Construct an FDESIGN object and call its CHEBY1 method.
[b1,a1] = cheby1(N,Apass,Wp,'low')
figure
freqz(b1,a1)
title('Magnitude and phase of IIR Chebsev filter ');
[Gd,w] = grpdelay(b1,a1,256);
figure;
plot(w,Gd); %Zoom in the plot to see the range from 0 to wp
xlabel(' 0 <= w <= wp ');
ylabel('Grp(H(ejw))');
title('Group Delay of IIR Chebsev filter ');

%....................................................................

%%Filtering the output...............................................


%Filter using kaiser Window
y1=filter(b,a,x) % filtering wideband signal
figure
plot(y1)
title('Filtered wideband signal using Kaisar window filter ');

%...............................................................
%Filter using IIR chebsev
z1=filter(b1,a1,x) % filtering wideband signal
figure
plot(z1)
title('Filtered wideband signal using IIR chebsev filter ');

%...............................................................

Answer 4
Group delay in FIR filter is higher as filtered output of it is more shifted compared to IIR filter also because
IIR filter has ORDER compared to FIR.

A narrowband FIR filter preserves the phase of the signal but experiences a significant
group delay because of the large number of taps required. An equivalent IIR filter has
fewer taps and thus would consume less computer resources

Narrowband

In radio, narrowband communication happens in a frequency range where the frequency response of the
channel is flat (where gain is constant for all the frequencies in the range). Therefore, the band should be
smaller than the coherence bandwidth (maximum range of frequencies where channel response is flat),
and relatively smaller than broadband range (or wideband) where channel response is not necessarily
flat.
When the data communication (or internet connections) is concerned, narrowband refers to the amount of
data being transferred within a second (or bits per second). Dial-up internet connection (where data rate
is less than 56 kbps) belongs to the narrowband internet category. In dial up connections, computers are
connected to internet through a modem and telephone cables.

Wideband

In radio, wideband communication happens in a wider frequency range compared to narrowband.


Wideband range exceeds the coherence bandwidth, and therefore, doesnt exhibit a flat frequency
response. Wideband is a relative term, and the size of the band may be in kHz, MHz or GHz depending
on the application.