Blekinge Institute of Technology Department of Telecommunication and Signal Processing

Telecoder Group, Applied Signal Processing Assignment

1

Blekinge Institute of Technology Department of Telecommunication and Signal Processing

Group Members
Adnan Saleem
E-mail:electropall@hotmail.com Student Personal No: 810524-P510

Syed Majid Ali Shah
E-mail:syedmaji@hotmail.com Student Personal No: 800321-1714

Syed Hassan Shaheed
E-mail:hassey22@yahoo.com Student Personal No: 800410-P732

Arif Ullah Khan
E-mail:arifullahkhan1@hotmail.com Student Personal No: 800323-P837

Telecoder Group, Applied Signal Processing Assignment

2

Blekinge Institute of Technology Department of Telecommunication and Signal Processing

Table of Contents
Assignment 1 --------------------------------------------------------------------------------------------------------- 5 Assignment 1.1------------------------------------------------------------------------------------------------------- 6 Assignment 1.2------------------------------------------------------------------------------------------------------- 9 Assignment 1.3------------------------------------------------------------------------------------------------------13 Assignment 1.4------------------------------------------------------------------------------------------------------17 Assignment 1.5------------------------------------------------------------------------------------------------------18 Assignment 1.6------------------------------------------------------------------------------------------------------21 Assignment 1.7------------------------------------------------------------------------------------------------------23 Assignment 1.8------------------------------------------------------------------------------------------------------26 Assignment 1.9------------------------------------------------------------------------------------------------------28 Assignment 1.10 ----------------------------------------------------------------------------------------------------30 Assignment 1.11 ----------------------------------------------------------------------------------------------------32 Assignment 1.12 ----------------------------------------------------------------------------------------------------34 Assignment 1.13 ----------------------------------------------------------------------------------------------------36 Assignment 1.14 ----------------------------------------------------------------------------------------------------37 Assignment 1.15 ----------------------------------------------------------------------------------------------------40 Assignment 1.16 ----------------------------------------------------------------------------------------------------43 Assignment 1.17 ----------------------------------------------------------------------------------------------------44 Assignment 1.18 ----------------------------------------------------------------------------------------------------46 Assignment 1.19 ----------------------------------------------------------------------------------------------------48 Assignment 2 --------------------------------------------------------------------------------------------------------49 Assignment 2.1------------------------------------------------------------------------------------------------------50 Assignment 2.2------------------------------------------------------------------------------------------------------52 Assignment 2.3------------------------------------------------------------------------------------------------------54 Assignment 2.4------------------------------------------------------------------------------------------------------56 Assignment 2.5------------------------------------------------------------------------------------------------------60 Assignment 2.6------------------------------------------------------------------------------------------------------62 Assignment 2.7------------------------------------------------------------------------------------------------------64 Assignment 2.8------------------------------------------------------------------------------------------------------68 Assignment 2.9------------------------------------------------------------------------------------------------------70 Assignment 2.10 ----------------------------------------------------------------------------------------------------72 Assignment 2.11 ----------------------------------------------------------------------------------------------------74 Assignment 2.12 ----------------------------------------------------------------------------------------------------75 Assignment 3 --------------------------------------------------------------------------------------------------------76 Assignment 3.1------------------------------------------------------------------------------------------------------77 Assignment 3.2------------------------------------------------------------------------------------------------------78 Assignment 3.3------------------------------------------------------------------------------------------------------80 Assignment 3.4------------------------------------------------------------------------------------------------------83 Assignment 3.5------------------------------------------------------------------------------------------------------85 Assignment 3.6------------------------------------------------------------------------------------------------------86 Assignment 3.7------------------------------------------------------------------------------------------------------92 Assignment 4 --------------------------------------------------------------------------------------------------------94 Assignment 4.1------------------------------------------------------------------------------------------------------95 Telecoder Group, Applied Signal Processing Assignment 3

154 Assignment Grade 4.Blekinge Institute of Technology Department of Telecommunication and Signal Processing Assignment 4.1---------------------------------------------------------------------------------------------------.4-------------------------------------------------------------------------------------------.10 -----------------------------------------------------------------------------------------.117 Assignment Grade 4.3-------------------------------------------------------------------------------------------.112 Assignment 5.115 Assignment for Grade 4-----------------------------------------------------------------------------------------.5-------------------------------------------------------------------------------------------.104 Assignment 4.6-------------------------------------------------------------------------------------------.9-------------------------------------------------------------------------------------------.2------------------------------------------------------------------------------------------------------97 Assignment 4.4---------------------------------------------------------------------------------------------------.151 Assignment Grade 4.144 Assignment Grade 4. Applied Signal Processing Assignment 4 .108 Assignment 5 -----------------------------------------------------------------------------------------------------.1-------------------------------------------------------------------------------------------.130 Assignment Grade 4.2-------------------------------------------------------------------------------------------.141 Assignment Grade 4.134 Assignment Grade 4.127 Assignment Grade 4.102 Assignment 4.118 Assignment Grade 4.113 Assignment 5.147 Assignment Grade 4.8-------------------------------------------------------------------------------------------.6---------------------------------------------------------------------------------------------------.2---------------------------------------------------------------------------------------------------.5---------------------------------------------------------------------------------------------------.3------------------------------------------------------------------------------------------------------99 Assignment 4.157 Telecoder Group.7-------------------------------------------------------------------------------------------.

Blekinge Institute of Technology Department of Telecommunication and Signal Processing Assignment 1 Telecoder Group. Applied Signal Processing Assignment 5 .

UnitS) title('Unit Step function'). delta(1. Applied Signal Processing Assignment 6 . delta=zeros(1. close all.delta.Blekinge Institute of Technology Department of Telecommunication and Signal Processing Assignment 1. figure(2) UnitS=ones(1. t=0:99. clc.1)=1.'*r') title('Unit Step function'). figure(3) stem(t. Telecoder Group. plot(t. plot(t.100).'*b') title('Unit Impulse function').UnitS.1 Matlab Code clear all.100).delta) title('Unit Impulse Function') figure(4) stem(t.

Blekinge Institute of Technology Department of Telecommunication and Signal Processing Figures Telecoder Group. Applied Signal Processing Assignment 7 .

Blekinge Institute of Technology Department of Telecommunication and Signal Processing Telecoder Group. Applied Signal Processing Assignment 8 .

2 Matlab Code clear all.a ) plot(n.1 Sum by Matlab= 1.^n.100).3780e+005 Telecoder Group. Applied Signal Processing Assignment 9 .5 Sum by Matlab= 2 Geometric sum = 2 a=0.3780e+005 Geometric sum = 1. func= a. n=0:99. S_matlab=sum(func) Geom_sum= (1 .*UnitS.func) title('Exponentially Decaying function') Results Time vector = 0:99 a=0.9997 a=1 Sum by Matlab= 100 Geometric sum = 100 a=1. a=input('Enter value of a ') UnitS=ones(1. clc.Blekinge Institute of Technology Department of Telecommunication and Signal Processing Assignment 1.9997 Geometric sum =9.a^100) /( 1 .9 Sum by Matlab= 9. close all.

Applied Signal Processing Assignment 10 .2677e+030 Figures Telecoder Group.Blekinge Institute of Technology Department of Telecommunication and Signal Processing a=2 Sum by Matlab= 1.2677e+030 Geometric sum = 1.

Applied Signal Processing Assignment 11 .Blekinge Institute of Technology Department of Telecommunication and Signal Processing Telecoder Group.

Applied Signal Processing Assignment 12 .Blekinge Institute of Technology Department of Telecommunication and Signal Processing Telecoder Group.

5 1/sqrt(5)]. for k=1:6 x(:.k)) end sound(x(:.2)) pause sound(x(:.6)) Figures Telecoder Group.5)) pause sound(x(:.Blekinge Institute of Technology Department of Telecommunication and Signal Processing Assignment 1.1)) pause sound(x(:. f=[0 1/16 1/8 1/4 0.4)) pause sound(x(:. close all. figure(k) plot(n. fs=2.3)) pause sound(x(:. n=0:1/fs:(8192-1)/fs.k)=cos(2*pi*f(k)*n).x(:.3 Matlab Code clear all. clc. Applied Signal Processing Assignment 13 .

Blekinge Institute of Technology Department of Telecommunication and Signal Processing Telecoder Group. Applied Signal Processing Assignment 14 .

Blekinge Institute of Technology Department of Telecommunication and Signal Processing

Telecoder Group, Applied Signal Processing Assignment

15

Blekinge Institute of Technology Department of Telecommunication and Signal Processing

Telecoder Group, Applied Signal Processing Assignment

16

Blekinge Institute of Technology Department of Telecommunication and Signal Processing

Assignment 1.4
Matlab Code clear all; close all; clc; fs=2; n=0:1/fs:(8192-1)/fs; f1= 1/8 - 1/8192; f2= 1/8 + 1/8192; x1=cos(2*pi*f1*n); x2=cos(2*pi*f2*n); x=x1 + x2; sound(x) pause sound(x1) pause f1 = 0.5 - 1/8192; x1= cos(2*pi*f1*n); sound(x1) Results Summation of two signals gives beat only first signal with one frequency doesn’t have any beat.

Telecoder Group, Applied Signal Processing Assignment

17

k). f= [1/8 7/8 9/8].x(:.'fontsize'. close all.'fontsize'.'fontsize'.12) title(' Cosine Signal '.14) end Telecoder Group.'fontsize'.14) end if k==3 plot(n. clc.k).Blekinge Institute of Technology Department of Telecommunication and Signal Processing Assignment 1.5 Matlab Code clear all.x(:. fs=512.'g') gtext('Signal frequency is 9/8 Hz'. n=0:1/fs:(8192-1)/fs. for k=1:3 x(:.'fontsize'.12) title(' Cosine Signal '. figure(k) if k==1 plot(n.12) title(' Cosine Signal '.k).14) end if k==2 plot(n.k)=cos(2*pi*f(k)*n).x(:.'b') gtext('Signal frequency is 1/8 Hz'.'fontsize'. Applied Signal Processing Assignment 18 .'r') gtext('Signal frequency is 7/8 Hz'.

Blekinge Institute of Technology Department of Telecommunication and Signal Processing end Figures Telecoder Group. Applied Signal Processing Assignment 19 .

Applied Signal Processing Assignment 20 .Blekinge Institute of Technology Department of Telecommunication and Signal Processing Telecoder Group.

plot(n.6 Matlab Code clear all. n=0:1/fs:(8192-1)/fs. plot(n.x). pause sound(real(x)) pause sound(imag(x)) Figures Telecoder Group. fs=512. a=3.14) sound(x).imag(x).2) title(' Exponential Signal '. 'fontsize'.real(x). close all.abs(x). f0=5.'m') legend( 'pure signal'.'absolute of signal'.'g').'real part of signal'. hold on.'r'). x = exp(log(a)*n + sqrt(-1)*2*pi*f0*n). clc. pause sound(abs(x)).'imaginary part of signal'. plot(n. Applied Signal Processing Assignment 21 . plot(n.Blekinge Institute of Technology Department of Telecommunication and Signal Processing Assignment 1.

Applied Signal Processing Assignment 22 .Blekinge Institute of Technology Department of Telecommunication and Signal Processing Telecoder Group.

Applied Signal Processing Assignment % chirp signal 23 . close all.'r').1.'fontsize'.delay). fs=1024.2. sound(y) figure(4) plot(ty. [y. f1 is 1/8192') delay = 2.5. t=0:1/fs:(8192-1)/fs.5-(1/(8192)))*t). x3 = x2 + x1. y=chirp(t1.Blekinge Institute of Technology Department of Telecommunication and Signal Processing Assignment 1.3.1.y) Telecoder Group.0. figure(1) plot(y. clc. x2=cos(2*pi*((1/2)+(1/(8192)))*t).x3.'fir'. Signal with sum of adjacent frequencies') gtext('f0 is 0. sound(x3) figure(2) plot(t. x1=cos(2*pi*(0. t1=0:1/fs:(16384*5-1)/fs..100).ty] = rcosflt(y.'b') title('Beating effect. title('Chirp signal'.14) fs=2.7 Matlab Code clear all.

Blekinge Institute of Technology Department of Telecommunication and Signal Processing title(' Vibration effect by using Delay in chirp signal') Figures Telecoder Group. Applied Signal Processing Assignment 24 .

Applied Signal Processing Assignment 25 .Blekinge Institute of Technology Department of Telecommunication and Signal Processing Telecoder Group.

close all. x=cos(2*pi*f2*n).xy) title('Alteration of two frequencies'. Applied Signal Processing Assignment 26 . xy=[x y x y x y x y].Blekinge Institute of Technology Department of Telecommunication and Signal Processing Assignment 1. clc. n=0:1/fs:(8192*8-1)/fs. n=[n n n n n n n n] sound(xy) plot(n. fs=8. y=cos(2*pi*f1*n).'fontsize'. f2 = 10') Telecoder Group.8 Matlab Code clear all.14) gtext('f1 = 20. f1=20. f2=10.

Blekinge Institute of Technology Department of Telecommunication and Signal Processing Figures Telecoder Group. Applied Signal Processing Assignment 27 .

'fontsize'.8191. n=linspace(0.0625*n)'. close all.'b') title('Signal. end figure(2) plot(n(1:length(y)).k)=x(k)-x(k-1).'r') title('Impulse Response'.8192).x(1:200).0625*n). for k=2:500 y(:.Blekinge Institute of Technology Department of Telecommunication and Signal Processing Assignment 1. figure(1) plot(n(1:200).'fontsize'. Applied Signal Processing Assignment 28 .14) y(:. clc.1)=x(1). 1+cos(2*pi*0.14) Telecoder Group.y.9 Matlab Code clear all. x=1+cos(2*pi*0.

Blekinge Institute of Technology Department of Telecommunication and Signal Processing Figures Telecoder Group. Applied Signal Processing Assignment 29 .

n = 0:1:255. yy=zeros(256. for k=1:256 yy(1:k. x = 1 + cos(2*pi*0. YY=[].1:k)).256).YY) title('Filter calculating Cumulative sum'.0625*n)') Telecoder Group. YY=sum(yy).14) gtext(' 1 + cos(2*pi*0. close all. Applied Signal Processing Assignment 30 . End plot(n.0625*n).10 Matlab Code clear all.k)=(x(1.Blekinge Institute of Technology Department of Telecommunication and Signal Processing Assignment 1. clc.'fontsize'.

Blekinge Institute of Technology Department of Telecommunication and Signal Processing Figures Telecoder Group. Applied Signal Processing Assignment 31 .

3).14) Telecoder Group.1)=x(1.(m-1))+x(1. y(1.(m-2))+x(1.nn). end stem(y.m).11 Matlab Code clear all. clc.1)+x(1. y(1.2)=x(1.(m-3))+x(1. y(1.Blekinge Institute of Technology Department of Telecommunication and Signal Processing Assignment 1.'fontsize'.m)=x(1.1)+x(1. close all n=1:100. Applied Signal Processing Assignment 32 . nn=length(n).2).4)=x(1. x=zeros(1.2)+x(1.4).(m-4))+x(1.1).1)=1. y(1. y(1.3)=x(1.1)+x(1.'r').3)+x(1. x(1. title('Impulse response'.2)+x(1. for m=5:100.

Blekinge Institute of Technology Department of Telecommunication and Signal Processing Figures Telecoder Group. Applied Signal Processing Assignment 33 .

yy=zeros(1. y=zeros(1. Y(1.k) X(1.8192).k-2) X(1. x=1 + cos(2*pi*f0*n). p=1.8171. end p=p+1. f0=0. end if t==-10 yy(1.k-3)]. End Telecoder Group.p)=10.k-3)=median(yy). close all. Applied Signal Processing Assignment 34 . for m=-17:8171 k=m+21.8192). yy=[X(1.Blekinge Institute of Technology Department of Telecommunication and Signal Processing Assignment 1.8192).025.p)=10. n=linspace(-20. end X=y-yy+x. for t=-20:1:79 if t==-20 y(1.12 Matlab Code clear all.k-1) X(1. clc.

Figures Telecoder Group.Blekinge Institute of Technology Department of Telecommunication and Signal Processing figure(1) plot(n(1:length(Y)).Y) title('GLIDING MEAN OF 10?(n ? 10) ? 10?(n ? 20) + x(n) = 1+cos(2*pi*f0*n)' ). Applied Signal Processing Assignment 35 .

Applied Signal Processing Assignment 36 . clc. y=[1 3 2]. Conv_xy= conv(x.0000 10 7.13 Matlab Code clear all.y) Results Conv_xy = 1 5 11 17 23 23 0 2.y) Cross_corr=xcorr(x. close all.0000 19.0000 13.0000 19.0000 5.Blekinge Institute of Technology Department of Telecommunication and Signal Processing Assignment 1.0000 Telecoder Group.0000 Cross_corr = 0. x=[1 2 3 4 5].0000 25.

10 using CONV ') load assign1_11 conv1_11=conv(x. clc. figure(3) stem(conv1_11(1:50)) title('Impulse response of assignment 1.Blekinge Institute of Technology Department of Telecommunication and Signal Processing Assignment 1.y). load assign1_9 conv1_9=conv(x. Applied Signal Processing Assignment 37 . figure(1) stem(conv1_9(1:50)) title('Impulse response of assignment 1.9 using CONV ') load assign1_10 conv1_10=conv(x. figure(2) stem(conv1_10(1:50)) title('Impulse response of assignment 1.11 using CONV ') Telecoder Group.y).14 Matlab Code clear all.y). close all.

Applied Signal Processing Assignment 38 .Blekinge Institute of Technology Department of Telecommunication and Signal Processing Figures Telecoder Group.

Applied Signal Processing Assignment 39 .Blekinge Institute of Technology Department of Telecommunication and Signal Processing Telecoder Group.

load assign1_9 filt1_9=filter(x.y).1.1.11 using FILT ') Telecoder Group.Blekinge Institute of Technology Department of Telecommunication and Signal Processing Assignment 1.10 using FILT ') load assign1_11 filt1_11=filter(x. clear all. figure(1) stem(filt1_9(1:50)) title('Impulse response of assignment 1.1. figure(2) stem(filt1_10(1:50)) title('Impulse response of assignment 1. figure(3) stem(filt1_11(1:50)) title('Impulse response of assignment 1.y). clc. Applied Signal Processing Assignment 40 .15 Matlab Code close all.y).9 using FILT ') load assign1_10 filt1_10=filter(x.

Blekinge Institute of Technology Department of Telecommunication and Signal Processing Figures Telecoder Group. Applied Signal Processing Assignment 41 .

Blekinge Institute of Technology Department of Telecommunication and Signal Processing Telecoder Group. Applied Signal Processing Assignment 42 .

y1=filter(conv1_9. load assign1_9 conv1_9=conv(x. p2=[1].16 Matlab Code clear all.11 data %% loading assignment 1. clc. close all. N=25.Blekinge Institute of Technology Department of Telecommunication and Signal Processing Assignment 1.yy).yy). sound(y1) pause. load assign1_11 conv1_11=conv(x.N).y).p2. load handel.1)=1.9 data Telecoder Group.y).p2. p1(1. Applied Signal Processing Assignment 43 . n=zeros(1. yy=y. p1=n. sound(y2) %% Press any key to listen sound of using filter in assignment 11 %% loading assignment 1. y2=filter(conv1_11.

hold on stem(y. legend('Impluse response'.Blekinge Institute of Technology Department of Telecommunication and Signal Processing Assignment 1.^n).17 Matlab Code clear all. n=1:1:50. close all. plot(h).50). y=((0.x).'Step response') Telecoder Group.*cos(pi*n/6).5). x=ones(1. clc. h=h+r.'r') title('IMPULSE RESPONSE AND STEP RESPONSE'). [r h]=deconv(y. Applied Signal Processing Assignment 44 .

Blekinge Institute of Technology Department of Telecommunication and Signal Processing Figures Telecoder Group. Applied Signal Processing Assignment 45 .

clc.x). h=((0.'r') title('IMPULSE RESPONSE AND STEP RESPONSE'). legend('Impulse response'.50). hold on stem(y(1:length(h)).'Step response') [h r]= deconv(y. plot(h). figure plot(h) title('Regained Impulse response from deconvultion') Telecoder Group.*cos(pi*n/6).^n). y =conv(h. x=ones(1. close all.5).Blekinge Institute of Technology Department of Telecommunication and Signal Processing Assignment 1. n=1:1:50.x). Applied Signal Processing Assignment 46 .18 Matlab Code clear all.

Applied Signal Processing Assignment 47 .Blekinge Institute of Technology Department of Telecommunication and Signal Processing Figures Telecoder Group.

p)=sin(2*pi*k*f*t). %% summation of all the harmonics sound(yy) yyy=yy'. sound(Y) %% Removal of 1st harmonic Telecoder Group. end yy=sum(y(:. Applied Signal Processing Assignment 48 . f=13. clc.19 Matlab Code clear all. Y=yyy-y(:. for k=6:15 p=k-5.Blekinge Institute of Technology Department of Telecommunication and Signal Processing Assignment 1. close all.1). y(:.1:10)'). t=0:1/8:(16384*2-1)/8.

Blekinge Institute of Technology Department of Telecommunication and Signal Processing Assignment 2 Telecoder Group. Applied Signal Processing Assignment 49 .

Blekinge Institute of Technology Department of Telecommunication and Signal Processing Assignment 2. Poles=roots(a) Zeros=roots(b) n=100.^n .a.1 Matlab Code clear all. a=[1 -1 0. %% no. clc.h) xlabel('Time') title('Impulse Response'.5 0].n).14) hold on n=0:99. b=[1 -0.* cos(pi*n.H.t] = impz(b./4). close all. stem(t. Applied Signal Processing Assignment 50 . plot(t.5].'Theoretical Calculation') Telecoder Group.'fontsize'. of samples to be used in impulse response [h.'or') legend('Impz function'. H= (1/sqrt(2)).

Applied Signal Processing Assignment 51 .Blekinge Institute of Technology Department of Telecommunication and Signal Processing Figures Telecoder Group.

t] = impz(b.'*r'). a=[1 -1 -1 1].Blekinge Institute of Technology Department of Telecommunication and Signal Processing Assignment 2. %% no.h. Telecoder Group.a.'fontsize'.'Zeros') n=200. of samples to be used in impulse response [h. clc.k.'ob'). legend('Poles'. hold on grid on plot(Zeros. b=[1 0 0 0].2 Matlab Code clear all. figure(2) stem(t.a) H=r(1)*(-1). Applied Signal Processing Assignment 52 .'ob') xlabel('Time') title('Impulse Response'. [r p k]=residue(b.14) hold on n=1:200.^n + r(2) + r(3)*n .n). close all. Poles=roots(a) Zeros=roots(b) figure(1) grid on plot(Poles.

2) Figures Telecoder Group.Blekinge Institute of Technology Department of Telecommunication and Signal Processing plot(t.'Theoritical calculations'. Applied Signal Processing Assignment 53 .H.'*r') legend('Impz function'.

Telecoder Group. figure(2) stem(t. hold on grid on plot(Zeros. %% no.Blekinge Institute of Technology Department of Telecommunication and Signal Processing Assignment 2. Applied Signal Processing Assignment 54 .n). clc. b=[1 zeros(1.t] = impz(b.14)].'ob').14) hold on u=[ones(1. legend('Poles'. close all. U=[zeros(1.'Zeros') n=100.a.length(u)-15)].'*r').100)]. of samples to be used in impulse response [h. a=[1 -1 zeros(1.14) -1].h. uu=u-U.'b') xlabel('Time') title('Impulse Response'.'fontsize'. Poles=roots(a) Zeros=roots(b) figure(1) grid on plot(Poles.3 Matlab Code clear all.15) ones(1.

Applied Signal Processing Assignment 55 .'*r') legend('Impz function'.'Easy Realization of same system'.Blekinge Institute of Technology Department of Telecommunication and Signal Processing plot(t.uu.1) Figures Telecoder Group.

4 Matlab Code clear all.a.a.a.Blekinge Institute of Technology Department of Telecommunication and Signal Processing Assignment 2.2 0]. Y=filter(b. Applied Signal Processing Assignment 56 . load ecg figure(1) plot(ecg) title('ECG Signal'.'Filtered Signal using flipud'.a.'Filtered signal using filtfilt') title('Filtered Signal using different Functions'.'fontsize'.'fontsize'.h) Telecoder Group.14) b=[0.'g') legend('Twice filtered signal'.t] = impz(b. figure(2) plot(Yf.'b') hold on Yff=flipud(ecg).14) [h.ecg). close all. plot(Yfff.Y).length(ecg)). hold on plot(Yff. Yf=filter(b. a=[1 -0. figure(3) plot(t.8].ecg). clc.'r') Yfff=filtfilt(b.

h).'b') hold on yf=conv(Yf. plot(yfff.'r') hold on yff=conv(Yff. figure(4) plot(y.14) y = conv(ecg. Applied Signal Processing Assignment 57 .h).'filtfilt') axis([0 4500 -225 800]) Telecoder Group.h).Blekinge Institute of Technology Department of Telecommunication and Signal Processing title('Impulse Response'. plot(yff.'fontsize'.h).'g') hold on yfff=conv(Yfff.'fontsize'.14) legend('Twice using filter'.'flipud'. hold on plot(yf.'k') title('Output Signal Filtered by different Matlab functions'.

Blekinge Institute of Technology Department of Telecommunication and Signal Processing Figures Telecoder Group. Applied Signal Processing Assignment 58 .

Applied Signal Processing Assignment 59 .Blekinge Institute of Technology Department of Telecommunication and Signal Processing Telecoder Group.

5 Matlab Code clear all. a = [1 -0.Blekinge Institute of Technology Department of Telecommunication and Signal Processing Assignment 2.a). plot(phi) title('Phase function of H(z)') Telecoder Group. %% Numerator coefficient %% Denominator coefficient [Hr.*Hr).8]. HR=abs(Hr. plot((HR)) title('Amplitude function of H(z)') figure(2) phi = angle(Hr).w] = zerophase(b. close all. Applied Signal Processing Assignment 60 .2 0]. b = [0. clc.

Blekinge Institute of Technology Department of Telecommunication and Signal Processing Figures Telecoder Group. Applied Signal Processing Assignment 61 .

2*0.8^2 . [H.W]=freqz(h).abs(H_th). plot(y) title('Phase function') %% Numerator coefficient Telecoder Group. a = [1 -0.abs(H).'--r') legend('freqz function'. figure(1) semilogy(W.8*cos(W)))). b = [0. [h.'Hand calculation') title('Frequency Function Comparison') figure(2) y = angle(H).'b') hold on H_th=(0. clc./((sqrt(1 + 0.a).8].2 0]. close all.2).Blekinge Institute of Technology Department of Telecommunication and Signal Processing Assignment 2.6 Matlab Code clear all. Applied Signal Processing Assignment 62 .t]=impz(b. semilogy(W.

Applied Signal Processing Assignment 63 .Blekinge Institute of Technology Department of Telecommunication and Signal Processing Figures Telecoder Group.

figure(3) stem(W.a. close all.abs(H)) title('Impulse response using 8 points') %% using 16 points [H.7 Matlab Code clear all.W]=impz(b.abs(H)) title('Impulse response using 16 points') %% using 32 points [H.W]=impz(b. a = [1 -0.32).abs(H)) Telecoder Group.a.a. figure(2) stem(W.a. clc.W]=impz(b.Blekinge Institute of Technology Department of Telecommunication and Signal Processing Assignment 2. b = [0. %% using 4 points [H.8).W]=impz(b.2 0].abs(H)) title('Impulse response using 4 points') %% using 8 points [H.4). figure(4) stem(W.16). figure(1) stem(W.8]. Applied Signal Processing Assignment %% Numerator coefficient 64 .

abs(H)) title('Impulse response using untruncated filter') Figures Telecoder Group.Blekinge Institute of Technology Department of Telecommunication and Signal Processing title('Impulse response using 32 points') %% Untruncated filter [H. figure(5) stem(W.a).W]=impz(b. Applied Signal Processing Assignment 65 .

Blekinge Institute of Technology Department of Telecommunication and Signal Processing Telecoder Group. Applied Signal Processing Assignment 66 .

Blekinge Institute of Technology Department of Telecommunication and Signal Processing Telecoder Group. Applied Signal Processing Assignment 67 .

HHH = abs(HH). h=h'.Blekinge Institute of Technology Department of Telecommunication and Signal Processing Assignment 2. H(:.8 Matlab Code clear all. n=0:43.a).2 0]. plot(HHH. k=1:44. Applied Signal Processing Assignment 68 .t]=impz(b. end plot(abs(H). a = [1 -0.' Using FFT function') %% Numerator coefficient Telecoder Group.'*b') hold on HH = fft(h). for k=0:43 E = h(1:44). b = [0.*exp(i*2*pi*k*n/44).8].k+1) = EE.'g') title(' Discrete fourier transform ') legend(' Matrix multiplication '. EE = sum(E). close all. clc. [h.

Blekinge Institute of Technology Department of Telecommunication and Signal Processing Figures Telecoder Group. Applied Signal Processing Assignment 69 .

a = [1 -0.a. plot(abs(H).2 0]. clc.a.W]=impz(b. Applied Signal Processing Assignment %% Numerator coefficient 70 . H = fft(h.512). toc title('Fourier Transform of Impulse') Telecoder Group. [h.8). hold on [h. H = fft(h.9 Matlab Code clear all. H = fft(h.W]=impz(b.'g').512).a.16). plot(abs(H).'k'). format long tic b = [0.512). hold on [h. close all.W]=impz(b.32).4). plot(abs(H).'r'). plot(abs(H).'b').a. hold on [h.W]=impz(b.8].512). H = fft(h.Blekinge Institute of Technology Department of Telecommunication and Signal Processing Assignment 2.

Applied Signal Processing Assignment 71 .'8 points'.Blekinge Institute of Technology Department of Telecommunication and Signal Processing legend('4 points'.'16 points'.4) Figures Telecoder Group.'32 points'.

So it is not included in the code. H = fft(h.W]=impz(b.'b'). plot(abs(H).a. hold on [h. hold on [h.31).8]. a = [1 -0.2 0].'k').W]=impz(b.3). plot(abs(H).512).'g'). H = fft(h. plot(abs(H).512).512). clc. close all.W]=impz(b.10 According to the email reply. H = fft(h.a.512). format long tic b = [0. hold on [h.7). toc Telecoder Group.'r'). plot(abs(H). [h. Applied Signal Processing Assignment 72 %% Numerator coefficient .W]=impz(b.15).a.Blekinge Institute of Technology Department of Telecommunication and Signal Processing Assignment 2. flops function is obsolete in Matlab now. H = fft(h. Matlab Code clear all.a.

Applied Signal Processing Assignment 73 .'16 points'.Blekinge Institute of Technology Department of Telecommunication and Signal Processing title('Fourier Transform of Impulse') legend('4 points'.4) Figures Telecoder Group.'32 points'.'8 points'.

8).4).4).5000 -0.* B.5000 -0.Blekinge Institute of Technology Department of Telecommunication and Signal Processing Assignment 2.0000 -0.* B. ab_4 = real(ifft(AB)) ab_conv = conv(a. close all. AB = A .b) A = fft(a.0000 -0.2500 -0. B = fft(b.8).0000 %% IDFT of 8 points fft %% IDFT of 4 point fft %% Convolution Telecoder Group.2500 -0. AB = A .1250 -0. clc. Applied Signal Processing Assignment 74 . B = fft(b. a = [ 1 -1 ]. ab_8 = real(ifft(AB)) Results ab_4 = 0.1250 ab_conv = 1. b = [ 1 0.5000 -0.125 ].1250 -0.2500 -0.1250 ab_8 = 1.25 0.1250 0 0 0.8750 -0.5 0. A = fft(a.11 Matlab Code clear all.

[h .a. yy = real(ifft(X.2 0]. clc. close all.12 Matlab Code clear all. Applied Signal Processing Assignment 75 .73113). a = [1 -0. H = fft(h.8192). X = fft(y.8192).8].*H)).Blekinge Institute of Technology Department of Telecommunication and Signal Processing Assignment 2. load handel b=[0. sound(yy) Telecoder Group. t] = impz(b.

Blekinge Institute of Technology Department of Telecommunication and Signal Processing Assignment 3 Telecoder Group. Applied Signal Processing Assignment 76 .

Applied Signal Processing Assignment 77 . A = 1.1 Matlab Code clear all. N = 256.Blekinge Institute of Technology Department of Telecommunication and Signal Processing Assignment 3. clc. k = 50. x = A * sin(2*pi*k/N*(0:255)). close all. plot(x) title('Sinusoid with k=50') Figures Telecoder Group.

X = fft(x). clc.^2. x = A * sin(2*pi*(k)/N*(0:255)). A = 1. k = 63.2 Matlab Code clear all. close all. periodogram(x) Telecoder Group.'r') title(' PSD using fft in db scale ') gtext('k=5 for signal') figure(2) [Pxx.w] = periodogram(x). Applied Signal Processing Assignment 78 .Blekinge Institute of Technology Department of Telecommunication and Signal Processing Assignment 3. XX = 1/N*abs(X). N = 256. figure(1) plot(10*log10(XX).

Blekinge Institute of Technology Department of Telecommunication and Signal Processing Figures Telecoder Group. Applied Signal Processing Assignment 79 .

Blekinge Institute of Technology Department of Telecommunication and Signal Processing Assignment 3.*w'. plot(f.(Pxx)) Telecoder Group. f=20. clc.f] = periodogram(x. sf = 2*(1/sum(w))^2. Applied Signal Processing Assignment 80 . XX =2*sf*abs(X).'r') title(' PSD scaled to Amplitude using fft ') figure(2) [Pxx. N = 256. xx = sqrt(XX).3 Matlab Code We have to repeat the same code for k=5 clear all. x = A * sin(2*pi*f*t). A = 1. figure(1) plot(f. f=0:fs/N:(fs-1)/2.abs(xx(1:length(f))). X = fft(wx). Pxx = sqrt(2*2*abs(Pxx)). close all. w = flattopwin(N).256. fs=128. t = 0:1/fs:(255)/fs. wx = x.fs).^2.w.

Applied Signal Processing Assignment 81 .Blekinge Institute of Technology Department of Telecommunication and Signal Processing title('PSD scaled to Amplitude using periodogram') Figures Telecoder Group.

Blekinge Institute of Technology Department of Telecommunication and Signal Processing Telecoder Group. Applied Signal Processing Assignment 82 .

Comparison between peaks is done in dB scale.Blekinge Institute of Technology Department of Telecommunication and Signal Processing Assignment 3. Also the Welch periodogram needs to be scaled so we multiply it with N/k.4 Details Here we have to compare the peak values by using different Matlab commands. Leakage produces magnitude error in the signal in the frequency domain.abs(Pxx)) figure(2) T=periodogram(x) periodogram(x) db_max=max(T) %% Conversion in to dB scale linear_max=N/63*10*log10(max(abs(Pxx))) Figures Telecoder Group.w] = pwelch(x). So the spectrum which we obtain from Welch periodogram. we convert it into dB.6785 Maximum amplitude value from periodogram (Matlab function) = 20.3718 % Magnitude error = 1. figure(1) plot(w/pi.e. Applied Signal Processing Assignment 83 . Maximum amplitude value from Welch periodogram = 20.48% Here in the sinusoidal signal there is no leakage. x = A * sin(2*pi*(k)/N*(0:255)). Matlab Code A = 1. One command is periodogram to compute PSD and the other is pwelch which use Welch periodogram method. If we encounter leakage in the signal then we have to use window i. time signal should be multiplied with time window. [Pxx. k = 63. N = 256.

Applied Signal Processing Assignment 84 .Blekinge Institute of Technology Department of Telecommunication and Signal Processing Telecoder Group.

5 To reduce magnitude error. Similarly. wvtool(hanning(N)). 0. Window Bartlett Hamming Hanning Blackman Matlab Code clear all.g. E. we have to select window with large width of main lobe and peak side lobe. Applied Signal Processing Assignment 85 .Blekinge Institute of Technology Department of Telecommunication and Signal Processing Assignment 3. wvtool(blackman(N)).039063 0. hanning window decrease the magnitude error to 16%. N=64. wvtool(bartlett(N)).042969 0. close all. Some of them give nice approximation of amplitude error which is reduced but on the other hand they increase the frequency uncertainly.039063 0.050781 Main Lobe Width Telecoder Group. wvtool(hamming(N)). clc.. Different windows have different specifications.

Blekinge Institute of Technology Department of Telecommunication and Signal Processing Assignment 3. N=[32 64]. Applied Signal Processing Assignment 86 . close all. clc.6 Matlab Code clear all. for k=1:2 wvtool(bartlett(N(k))) wvtool(blackman(N(k))) wvtool(hamming(N(k))) wvtool(hann(N(k))) wvtool(flattopwin(N(k))) end Telecoder Group.

Applied Signal Processing Assignment 87 .Blekinge Institute of Technology Department of Telecommunication and Signal Processing Figures Telecoder Group.

Blekinge Institute of Technology Department of Telecommunication and Signal Processing Telecoder Group. Applied Signal Processing Assignment 88 .

Blekinge Institute of Technology Department of Telecommunication and Signal Processing Telecoder Group. Applied Signal Processing Assignment 89 .

Blekinge Institute of Technology Department of Telecommunication and Signal Processing Telecoder Group. Applied Signal Processing Assignment 90 .

Blekinge Institute of Technology Department of Telecommunication and Signal Processing Telecoder Group. Applied Signal Processing Assignment 91 .

f=0:fs/N:(fs-1)/2.fs). A = 1.^2. f=20.abs(xx(1:length(f))). x = A * sin(2*pi*f*t).256.*w'. Pxx = sqrt(2*2*abs(Pxx)). sf = 2*(1/sum(w))^2. clc.(Pxx)) title('PSD scaled to Amplitude using periodogram') Telecoder Group. wx = x. xx = sqrt(XX). plot(f. fs=128. figure(1) plot(f. XX =2*sf*abs(X). close all.w.Blekinge Institute of Technology Department of Telecommunication and Signal Processing Assignment 3. X = fft(wx). t = 0:1/fs:(255)/fs.'r') title(' PSD scaled to Amplitude using fft ') figure(2) [Pxx. Applied Signal Processing Assignment 92 . w = flattopwin(N).7 Matlab Code clear all. N = 256.f] = periodogram(x.

Blekinge Institute of Technology Department of Telecommunication and Signal Processing Figures Telecoder Group. Applied Signal Processing Assignment 93 .

Blekinge Institute of Technology Department of Telecommunication and Signal Processing Assignment 4 Telecoder Group. Applied Signal Processing Assignment 94 .

'hhat') >> Q Results Q = 0.'ob') >> hold on >> plot(hhat.Blekinge Institute of Technology Department of Telecommunication and Signal Processing Assignment 4. Applied Signal Processing Assignment 95 .'r') >> legend('h'. M: 128 plot(h.1056 Figures Telecoder Group.1 Command Window SNR [dB]: 2000 Antal koefficienter.

Blekinge Institute of Technology Department of Telecommunication and Signal Processing Telecoder Group. Applied Signal Processing Assignment 96 .

Applied Signal Processing Assignment 97 .'ob') >> legend('hhat'.'b') >> hold on >> plot(h. M: 128 >> Q Results Q = 6. M: 256 >> Q Results Q = 7.2169e+097 >> plot(hhat.Blekinge Institute of Technology Department of Telecommunication and Signal Processing Assignment 4.'h') gtext('SNR = 25 and M=256') Part B: SNR [dB]: 25 Antal koefficienter.'*r') >> legend('hhat'.'r') >> hold on >> plot(h.'h') >> gtext('SNR=25 M=128') Telecoder Group.9789e+045 >> plot(hhat.2 Part A: SNR [dB]: 25 Antal koefficienter.

Applied Signal Processing Assignment 98 .Blekinge Institute of Technology Department of Telecommunication and Signal Processing Telecoder Group.

Blekinge Institute of Technology Department of Telecommunication and Signal Processing

Assignment 4.3
Part A: corr64 SNR [dB]: 1500 Antal koefficienter, M: 256 Results Q = 0.0304 >> plot(hhat,'b') >> hold on >> plot(h,'*r') >> legend('hhat','h') >> gtext('SNR=1500 and M=256 Fft length=64') Figures Part B: corr128 SNR [dB]: 1500 Antal koefficienter, M: 256 Results Q = 0.0148 >> plot(hhat,'b') >> hold on >> plot(h,'*r') >> legend('hhat','h') >> gtext('SNR=1500 M=256 FFt length= 128') Result: Telecoder Group, Applied Signal Processing Assignment

99

Blekinge Institute of Technology Department of Telecommunication and Signal Processing

Part C: corr256 SNR [dB]: 1500 Antal koefficienter, M: 256 Results Q = 0.0157 >> plot(hhat,'b') >> hold on >> plot(h,'*r') >> legend('hhat','h') >> gtext('SNR=1500 M=256 FFt length= 256') Figures

Telecoder Group, Applied Signal Processing Assignment

100

Blekinge Institute of Technology Department of Telecommunication and Signal Processing

Telecoder Group, Applied Signal Processing Assignment

101

0302 >> plot(hhat. M: 256 Results Q = 0.4 Part A: corr 64 SNR [dB]: 25 Antal koefficienter.'b') >> hold on >> plot(h.Blekinge Institute of Technology Department of Telecommunication and Signal Processing Assignment 4.'h') >> gtext('SNR=25 M=256 FFT length=64') Part B: corr 128 Telecoder Group. Applied Signal Processing Assignment 102 .'*r') >> legend('hhat'.

M: 256 Results Q = 0.'b') >> hold on >> plot(h. Applied Signal Processing Assignment 103 .Blekinge Institute of Technology Department of Telecommunication and Signal Processing SNR [dB]: 25 Antal koefficienter.'h') >> gtext('SNR=25 M=256 FFT length=128') Figures Telecoder Group.0160 >> plot(hhat.'*r') >> legend('hhat'.

'*r') >> legend('hhat'.'h') >> gtext('SNR=25 M=256 FFT length=256') Figures Assignment 4. Applied Signal Processing Assignment 104 . M: 256 Results Q = 0.0293 >> plot(hhat.Blekinge Institute of Technology Department of Telecommunication and Signal Processing Part C: corr 256 SNR [dB]: 25 Antal koefficienter.'b') >> hold on >> plot(h.5 Telecoder Group.

0280 >> plot(hhat.'*r') >> legend('hhat'. Telecoder Group.'b') >> hold on >> plot(h.'h') >> gtext('SNR=25 M=256 ') Figures Part B: M=128.Blekinge Institute of Technology Department of Telecommunication and Signal Processing Part A: M=256 SNR [dB]: 1500 Antal koefficienter. M: 256 Results Q = 0. Applied Signal Processing Assignment 105 .

'h') >> gtext('SNR=1500 M=128 ') Part C: M=64 SNR [dB]: 1500 Telecoder Group.Blekinge Institute of Technology Department of Telecommunication and Signal Processing SNR [dB]: 1500 Antal koefficienter. M: 128 >> Q Results Q = 0.0024 >> plot(hhat.'b') >> hold on >> plot(h.'*r') >> legend('hhat'. Applied Signal Processing Assignment 106 .

'b') >> hold on >> plot(h.Blekinge Institute of Technology Department of Telecommunication and Signal Processing Antal koefficienter. M: 64 >> Q Results Q = 0.'*r') >> legend('hhat'.'h') >> gtext('SNR=1500 M=64 ') Telecoder Group. Applied Signal Processing Assignment 107 .0010 >> plot(hhat.

'b') >> hold on >> plot(h.'*r') >> legend('hhat'.'h') >> gtext('SNR=30 M=256 ') Telecoder Group.0031 >> plot(hhat.6 Part A: M=256 SNR [dB]: 30 Antal koefficienter.Blekinge Institute of Technology Department of Telecommunication and Signal Processing Assignment 4. Applied Signal Processing Assignment 108 . M: 256 >> Q Results Q = 0.

'b') >> hold on >> plot(h.'*r') >> legend('hhat'.7188e-004 >> plot(hhat.'h') >> gtext('SNR=30 M=128 ') Figures Telecoder Group.Blekinge Institute of Technology Department of Telecommunication and Signal Processing Figures Part B: M=128 SNR [dB]: 30 Antal koefficienter. M: 128 >> Q Results Q = 8. Applied Signal Processing Assignment 109 .

Blekinge Institute of Technology Department of Telecommunication and Signal Processing Part C: M=64 SNR [dB]: 30 Antal koefficienter.'b') >> hold on >> plot(h.0026 >> plot(hhat.'*r') >> legend('hhat'. M: 64 >> Q Results Q = 0. Applied Signal Processing Assignment 110 .'h') >> gtext('SNR=30 M=64 ') Result: Telecoder Group.

Blekinge Institute of Technology Department of Telecommunication and Signal Processing Telecoder Group. Applied Signal Processing Assignment 111 .

Applied Signal Processing Assignment 112 .Blekinge Institute of Technology Department of Telecommunication and Signal Processing Assignment 5 Telecoder Group.

close all. x=3*sin(2*pi*f*t).1 Matlab Code clear all. noise=randn(1. clc. N=512. t=0:1/fs:(N-1)/fs. Nx=xcorr(x. fs=512. X=xcorr(x).N). f=20. fopt=X\Nx. figure(1) plot(fopt) title('Optimal Filter') Telecoder Group. Applied Signal Processing Assignment 113 .Blekinge Institute of Technology Department of Telecommunication and Signal Processing Assignment 5.noise).

Applied Signal Processing Assignment 114 .Blekinge Institute of Technology Department of Telecommunication and Signal Processing Figures Telecoder Group.

N).close all. f=20. t=0:1/fs:(N-1)/fs. meu=meu_frac*(2/(((L+1) * mean(xn. e(n) = d(n) . d=filter([zeros(1.35. x=3*sin(2*pi*f*t). end plot(e) title('Error Signal') Telecoder Group. fs=512. delay=25. meu_frac=0. L=91.*xn)))).delay) 1]. d=randn(1. y(n) = xn * w.y(n).1).d).1.Blekinge Institute of Technology Department of Telecommunication and Signal Processing Assignment 5. w = w + meu * e(n)* xn'. e = zeros(size(x)). N=4096. y = zeros(size(x)). clc. for n=L:length(x) xn = x(n : -1 : n-L+1). 115 .2 Matlab Code clear all. Applied Signal Processing Assignment %y = Output from the filter % e = Error Signal. % d= Desired Signal w = zeros(L.

Applied Signal Processing Assignment 116 .Blekinge Institute of Technology Department of Telecommunication and Signal Processing Figures Telecoder Group.

Applied Signal Processing Assignment 117 .Blekinge Institute of Technology Department of Telecommunication and Signal Processing Assignment for Grade 4 Telecoder Group.

3 -26.035156 0.039063 Magnitude of the 1st side lobe -13. wvtool(w) w=hanning(M). close all.3 -31.054688 0. wvtool(w) end Results Window Rectangular Bartlett Hamming Hanning Blackman Rectangular Bartlett Hamming Hanning 51 51 51 51 51 71 71 71 71 M Main Lobe width 0.03125 0.1 Matlab Code clear all.1 -13.3 -26. w=boxcar(M). for k=1:3 M=m(k).5 -42. Applied Signal Processing Assignment . wvtool(w) w=blackman(M).Blekinge Institute of Technology Department of Telecommunication and Signal Processing Assignment Grade 4.5 -31.050781 0.050781 0.5 -58. m = [51 71 91].4 -42.5 118 %% Blackman window %% Hanning window %% Hamming window %% Bartlett window %% Rectangular window Telecoder Group. clc. wvtool(w) w=bartlett(M).023438 0. wvtool(w) w=hamming(M).035156 0.0625 0.

5 -58.03125 0.Blekinge Institute of Technology Department of Telecommunication and Signal Processing Blackman Rectangular Bartlett Hamming Hanning Blackman 71 91 91 91 91 91 0.5 -42.046875 0.3 -26.27344 0.027344 0.017578 0.1 Telecoder Group. Applied Signal Processing Assignment 119 .6 -31.035150 -58.1 -13.

Blekinge Institute of Technology Department of Telecommunication and Signal Processing Telecoder Group. Applied Signal Processing Assignment 120 .

Blekinge Institute of Technology Department of Telecommunication and Signal Processing Telecoder Group. Applied Signal Processing Assignment 121 .

Blekinge Institute of Technology Department of Telecommunication and Signal Processing Telecoder Group. Applied Signal Processing Assignment 122 .

Blekinge Institute of Technology Department of Telecommunication and Signal Processing Telecoder Group. Applied Signal Processing Assignment 123 .

Applied Signal Processing Assignment 124 .Blekinge Institute of Technology Department of Telecommunication and Signal Processing Telecoder Group.

Applied Signal Processing Assignment 125 .Blekinge Institute of Technology Department of Telecommunication and Signal Processing Telecoder Group.

Applied Signal Processing Assignment 126 .Blekinge Institute of Technology Department of Telecommunication and Signal Processing Telecoder Group.

plot(w2. Applied Signal Processing Assignment 127 . Telecoder Group.1.Blekinge Institute of Technology Department of Telecommunication and Signal Processing Assignment Grade 4.2).'g') title('Kaiser window Time domain') legend('Beta=1'. close all.'r') hold on L = 50.'b') hold on L = 50.1.512. plot(w3.B).f] = freqz(w2/sum(w2).'Beta=5'. w2 = kaiser(L. B = 1. w1 = kaiser(L. B = 5.2 Matlab Code clear all. L = 50. w3 = kaiser(L.512.B). [W2.'Beta=9') xlabel('Samples') ylabel('Amplitude') %%% Kaiser window in frequency domain [W1.B).2). B = 9.f] = freqz(w1/sum(w1). clc. plot(w1.

'Beta = 9'. grid.'Beta = 5'.20*log10(abs([W1 W2 W3]))). Applied Signal Processing Assignment 128 . figure(2) plot(f.f] = freqz(w3/sum(w3).3) Telecoder Group.2).512. xlabel('Normalized Frequency') ylabel('Magnitude (dB)') title('Kaiser Window in frequency domain') legend('Beta = 1'.Blekinge Institute of Technology Department of Telecommunication and Signal Processing [W3.1.

Applied Signal Processing Assignment 129 .Blekinge Institute of Technology Department of Telecommunication and Signal Processing Figures Telecoder Group.

w). M=51 and wc=0. w = ones(1.1. M=51 and wc=0.25') b = fir1(50.0. %% Rectangular window b = fir1(50.1.w). M=51 and wc=0. figure(4) freqz(b. M=51 and wc=0. M=51 and wc=0.25') figure(3) impz(b) title('Impulse Response. freqz(b.512) title('FIR1 Window Design Method For Rectangular window.0.51).25') figure(2) zplane(b) title('Poles and Zeros.5') Figures Telecoder Group.5') figure(6) impz(b) title('Impulse Response.25.Blekinge Institute of Technology Department of Telecommunication and Signal Processing Assignment Grade 4.5. Applied Signal Processing Assignment 130 .3 Matlab Code clear all.512) title('FIR1 Window Design Method For Rectangular window. M=51 and wc=0. clc. close all.5') figure(5) zplane(b) title('Poles and Zeros.

Applied Signal Processing Assignment 131 .Blekinge Institute of Technology Department of Telecommunication and Signal Processing Telecoder Group.

Applied Signal Processing Assignment 132 .Blekinge Institute of Technology Department of Telecommunication and Signal Processing Telecoder Group.

Blekinge Institute of Technology Department of Telecommunication and Signal Processing Telecoder Group. Applied Signal Processing Assignment 133 .

clc.Blekinge Institute of Technology Department of Telecommunication and Signal Processing Assignment Grade 4.0.4 Matlab Code clear all. M=71 and wc=0. freqz(b.1. w = ones(1.25') figure(2) zplane(b) title('Poles and Zeros.w).25') figure(5) zplane(b) title('Poles and Zeros. figure(4) freqz(b.71). close all. M=51 and wc=0.25') figure(3) impz(b) title('Impulse Response.w).51). M=51 and wc=0.512) m71 = ginput(2) title('FIR1 Window Design Method For Rectangular window.512) m51 = ginput(2) title('FIR1 Window Design Method For Rectangular window.25.25') %%% M = 71 w = ones(1. M=51 and wc=0. %% Rectangular window b = fir1(50. %% Rectangular window b = fir1(70.1.0. Applied Signal Processing Assignment 134 . M=71 and wc=0.25.25') Telecoder Group.

25.w).25') figure(9) impz(b) title('Impulse Response. Applied Signal Processing Assignment 135 .25') figure(8) zplane(b) title('Poles and Zeros. M=91 and wc=0.25') %%% M = 91 w = ones(1.7577 Figures 51 71 91 M Telecoder Group. M=91 and wc=0.25') Results Transition Band Width (Normalize frequency) 0.6767 -20.2760 -21.91).0389 0. %% Rectangular window b = fir1(90. M=71 and wc=0.512) m91 = ginput(2) title('FIR1 Window Design Method For Rectangular window.0. figure(7) freqz(b. M=91 and wc=0.Blekinge Institute of Technology Department of Telecommunication and Signal Processing figure(6) impz(b) title('Impulse Response.0169 M 51 71 91 Magnitude of 1st side lobe (dB) -20.1.0233 0.

Blekinge Institute of Technology Department of Telecommunication and Signal Processing Telecoder Group. Applied Signal Processing Assignment 136 .

Blekinge Institute of Technology Department of Telecommunication and Signal Processing Telecoder Group. Applied Signal Processing Assignment 137 .

Applied Signal Processing Assignment 138 .Blekinge Institute of Technology Department of Telecommunication and Signal Processing Telecoder Group.

Applied Signal Processing Assignment 139 .Blekinge Institute of Technology Department of Telecommunication and Signal Processing Telecoder Group.

Blekinge Institute of Technology Department of Telecommunication and Signal Processing Telecoder Group. Applied Signal Processing Assignment 140 .

freqz(b.5 Matlab Code clear all. Applied Signal Processing Assignment 141 .512) hann = ginput(3) wblack= blackman(71).0. clc.512) hamm = ginput(3) whann = hanning(71). wrect = boxcar(71). b = fir1(70.512) bart = ginput(3) whamm = hamming(71). b = fir1(70.1.1.25.1.whann). close all. freqz(b.0.25. freqz(b. freqz(b.25.25.0.1.1.0.Blekinge Institute of Technology Department of Telecommunication and Signal Processing Assignment Grade 4.wbart).0.25. freqz(b.whamm). b = fir1(70. b = fir1(70.wblack). b = fir1(70.512) rec = ginput(3) wbart = bartlett(71).wrect).512) blac = ginput(3) %% Kaiser window Telecoder Group.

0.512) w5k = ginput(3) B = 9.0688 142 Telecoder Group.1.0. b = fir1(70. b = fir1(70. B = 1.25. freqz(b.Blekinge Institute of Technology Department of Telecommunication and Signal Processing L = 71.512) w9k = ginput(3) M = 71 Results Window Rectangular Bartlett Hamming Stop band Attenuation (dB) -20. b = fir1(70.B).0246 0. freqz(b.512) w1k = ginput(3) B = 5.w1).w1).B). w1 = kaiser(L.1. w1 = kaiser(L.0.3913 -52.1. w1 = kaiser(L.w1). Applied Signal Processing Assignment .0688 0.1304 Transition width 0.B).4348 -26.25.25. freqz(b.

1025 Telecoder Group.3696 Beta 0.9130 -52.5000 Transition width 0.0779 0.Blekinge Institute of Technology Department of Telecommunication and Signal Processing Hanning Blackman Window Kaiser Kaiser Kaiser 1 5 9 -41. Applied Signal Processing Assignment 143 .7391 -73.1051 Stopband Attenuation dB -22.0272 0.0662 0.6957 -87.

Blekinge Institute of Technology Department of Telecommunication and Signal Processing

Assignment Grade 4.6
Matlab Code clear all; close all; clc; wp = 0.2; ws = 0.3; Rp = 0.25; As = 50; [N,wn] = buttord(wp,ws,Rp,As); [B,A] = butter(N,wn); w = 0:pi/255:pi; H = freqz(B,A,w); plot(w/pi,20*log10(abs(H))) M = N+1; disp(['Filter length is ',int2str(M)]) title('Low pass Butterworth filter') xlabel('Normalized Frequency') ylabel('Magnitude dB') figure(2) zplane(H) title('Poles and Zeros Plot') poles = roots(B) zeros = roots(A) Results Filter length is 17 Telecoder Group, Applied Signal Processing Assignment 144

Blekinge Institute of Technology Department of Telecommunication and Signal Processing poles = -1.2204 -1.1956 + 0.0974i -1.1956 - 0.0974i -1.1300 + 0.1691i -1.1300 - 0.1691i -1.0443 + 0.2012i -1.0443 - 0.2012i -0.9597 + 0.1941i -0.9597 - 0.1941i -1.0139 -0.8906 + 0.1570i -0.8906 - 0.1570i -0.8432 + 0.1008i -0.8432 - 0.1008i -0.8195 + 0.0346i -0.8195 - 0.0346i zeros = 0.7303 + 0.5917i 0.7303 - 0.5917i 0.6554 + 0.5106i 0.6554 - 0.5106i 0.5977 + 0.4291i 0.5977 - 0.4291i 0.5538 + 0.3485i 0.5538 - 0.3485i 0.5212 + 0.2692i 0.5212 - 0.2692i 0.4982 + 0.1912i 0.4982 - 0.1912i 0.4835 + 0.1142i 0.4835 - 0.1142i 0.4763 + 0.0380i 0.4763 - 0.0380i

Figures

Telecoder Group, Applied Signal Processing Assignment

145

Blekinge Institute of Technology Department of Telecommunication and Signal Processing

Telecoder Group, Applied Signal Processing Assignment

146

plot(w/pi. Applied Signal Processing Assignment 147 . clc.p*180/pi) title('Phase plot') ylabel('Phase [Degrees]'). wp = [0. w = 0:pi/255:pi.As).7 Matlab Code clear all. [N.65].8].A] = butter(N.wn] = buttord(wp. grid on figure(3) zplane(H) Telecoder Group.Blekinge Institute of Technology Department of Telecommunication and Signal Processing Assignment Grade 4. Rp = 1.Rp. close all. As = 60. H = freqz(B.20*log10(abs(H))) M = N+1.w).A.2 0. ws = [0. plot(w/pi. disp(['Filter length is '.int2str(M)]) title('Low pass Butterworth filter') xlabel('Normalized Frequency') ylabel('Magnitude dB') figure(2) p = unwrap(angle(H)). [B.35 0.ws.wn).

Applied Signal Processing Assignment 148 .Blekinge Institute of Technology Department of Telecommunication and Signal Processing title('Poles and Zeros Plot') poles = roots(B) zeros = roots(A) Figures Telecoder Group.

Blekinge Institute of Technology Department of Telecommunication and Signal Processing Telecoder Group. Applied Signal Processing Assignment 149 .

Applied Signal Processing Assignment 150 .Blekinge Institute of Technology Department of Telecommunication and Signal Processing Zoomed View Telecoder Group.

d1=(10^(rp/20)-1)/(10^(rp/20)+1).6*df)+1).8 Matlab Code clear all. title('Magnitude for Equiripple Filter') xlabel('Normalized frequency') ylabel('Magnitude. d2=(1-d1)*(10^(-As/20)). Figures Telecoder Group.2.25.1. dB') figure(2) zplane(h) title('Plot for Poles and zeros ') figure(3) plot(h) title('Impulse response of the filter'). h= firpm(M-1.Blekinge Institute of Technology Department of Telecommunication and Signal Processing Assignment Grade 4.2). freqz(h. close all. wp=0. As=50. Applied Signal Processing Assignment 151 .1024. ws=0.[0 wp ws 1].[1 1 0 0]. wt=[d2/d1 1].3. clc. rp=0.wt). df=(ws-wp)/(2*pi). M=ceil((-20*log10(sqrt(d1*d2))-13)/(14.

Blekinge Institute of Technology Department of Telecommunication and Signal Processing

Telecoder Group, Applied Signal Processing Assignment

152

Blekinge Institute of Technology Department of Telecommunication and Signal Processing

Telecoder Group, Applied Signal Processing Assignment

153

Blekinge Institute of Technology Department of Telecommunication and Signal Processing

Assignment Grade 4.9
Matlab Code clear all; close all; clc; Rp=1; As=60; k=(10^(-Rp/20)); d1=(1-k)/(1+k); k=(10^(-As/20)); d2=k*(1+d1); M=ceil((-20*log10(sqrt(d1*d2))-13)/(14.6*(.15/2))); N=M-1; wt=[1 d2/d1 1]; h= firpm(N,[0 0.2 0.35 0.65 0.8 1],[0 0 1 1 0 0],wt); freqz(h,1,512,2); title('Magnitude and Phase response of Equiripple Filter'); xlabel('Normalized Frequency') ylabel('Magnitude dB') figure(2) zplane(h) title('Poles and zeros of filer '); figure(3) stem(h) title('Impulse response of filer'); Figures Telecoder Group, Applied Signal Processing Assignment 154

Blekinge Institute of Technology Department of Telecommunication and Signal Processing Telecoder Group. Applied Signal Processing Assignment 155 .

Blekinge Institute of Technology Department of Telecommunication and Signal Processing Telecoder Group. Applied Signal Processing Assignment 156 .

d2=(1-d1)*(10^(-As/20)).08). Rp=.1.wt). Applied Signal Processing Assignment 157 . b=firpm(M-1.10 Matlab Code clear all.01). %generating a synosoidal signal t = 0:1/fs:(N-1)/fs.5-. t=t(1:200).x). clc fs = 200.(. close all.5-. Telecoder Group.freq_band.1.(.5+. x=x(1:200). freq_band=[0. N = 8192. sinus=cos(pi/2*t). fx=filter(b.01).(. %Generating 200 samples of signal to be filtered x=sinus+noise. %Passband ripple As=30.5+.Blekinge Institute of Technology Department of Telecommunication and Signal Processing Assignment Grade 4.1]. wt=[1 d2/d1 1].[0 0 1 1 0 0].N). % signal=signal(1:200).(. %Generating the noise signal noise=randn(1.08). M=51. %stopband attenuation d1=(10^(Rp/20)-1)/(10^(Rp/20)+1).

title('Input Signal'). Figures Telecoder Group. Applied Signal Processing Assignment 158 . figure(2) plot(t(100:200). figure(3) plot(t(100:200). title('Filtered Signal').2).1.Blekinge Institute of Technology Department of Telecommunication and Signal Processing %plotting the results freqz(b.fx(100:200)).512. title('Amplitude and Phase response of filter').x(100:200)).

Blekinge Institute of Technology Department of Telecommunication and Signal Processing Telecoder Group. Applied Signal Processing Assignment 159 .

Sign up to vote on this title
UsefulNot useful