DIGITAL SIGNAL PROCESSING(MATLAB) ECE LAB REPORT, Assignments of Digital Signal Processing

MATLAB CODE AND RESULT:- (a) Z transform and it;s inverse (b) FIR and IIR filter design (c) FIR and IIR filter design by Butter word method (d) Z transform numerical

Typology: Assignments

2019/2020

Uploaded on 06/29/2020

arunabh-bora
arunabh-bora ๐Ÿ‡ฎ๐Ÿ‡ณ

1 document

1 / 22

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Submitted By:-
Arunabh Bora
Roll No:- 180104004
4th Sem
Electronics and Communication Engineering
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16

Partial preview of the text

Download DIGITAL SIGNAL PROCESSING(MATLAB) ECE LAB REPORT and more Assignments Digital Signal Processing in PDF only on Docsity!

Submitted By:-

Arunabh Bora

Roll No:- 180104004

th

Sem

Electronics and Communication Engineering

Aim:- To find the z transform of a finite sequence

Theory :- In mathematics and Signal Processing the z transform converts a

discrete time signal which is a response of real or complex number into a

complex frequency domain representation

Mathematically ๐‘๐‘

โˆž

๐‘›๐‘›=

โˆ’๐‘›๐‘›

Matlab Code:-

%Z transform of finite sequences

clc;

close all;

clear all;

syms 'z';

disp('If you input a finite duration sequence x(n),we will

give you its z-transform');

nf=input('Please input the initial value of n = ');

nl=input('Please input the final value of n = ');

x= input('Please input the sequence x(n)= ');

syms 'm';

syms 'y';

f(y,m)=(y*(z^(-m)));

disp('Z-transform of the input sequence is displayed below');

k=1;

for n=nf:1:nl

answer(k)=(f((x(k)),n));

k=k+1;

end

disp(sum(answer));

Aim :- To plot the poles and zeros of

1โˆ’๐‘ง๐‘ง

โˆ’

โˆ’2๐‘ง๐‘ง

โˆ’

1โˆ’1.75๐‘ง๐‘ง

โˆ’

+1.25๐‘ง๐‘ง

โˆ’

โˆ’0.375๐‘ง๐‘ง

โˆ’

Theory :-

The roots of solution of variable S in characteristic equation are called poles of

the system of transfer function. The roots of solution of variable as in the

numerator polynomials are called zeros of the system of closed loop transfer

function.

Matlab Code :-

%to plot poles and zeros

clc;

clear all;

close all;

H=[1 1 2];

Q=[1 -1.75 1.25 -0.375];

zplane(H,Q);

grid on;

Result :-

Conclusion :-

From the above experiment we get our result and itโ€™s successfully

executed.

Aim :- (๐‘–๐‘–)Find Residue Term and convert back to ๐‘ฅ๐‘ฅ(๐‘›๐‘›)

๐‘ง๐‘ง

3๐‘ง๐‘ง

2

โˆ’4๐‘ง๐‘ง+

(๐‘–๐‘–๐‘–๐‘–) Find ๐‘ง๐‘ง

โˆ’

Theory :- In complex analysis a discipline within mathematics the Residue

theorem sometime called โ€˜Cauchyโ€™s Residue theoremโ€™ is a powerful tool to

evaluate line integrals of analytic function over closed curve can often be used

to compute real integrals and infinite series as well.

Matlab Code :-

%Residue term and connect back to x(n)

clc;

clear all;

close all;

b = [0 10];

a= [3 -4];

[r,p,c]= residuez(b,a);

%Residue term and connect back to x(n)and find z^-

clc;

clear all;

close all;

r=[0.5000,-0.5000];

p=[1.0000,-0.3333];

c=[?];

[b,a]=residuez(r,p,c);?

Aim :- Determine inverse z transform of

1+0.4โˆš2 ๐‘ง๐‘ง

โˆ’

1โˆ’0.8โˆš2๐‘ง๐‘ง

โˆ’

+0.64๐‘ง๐‘ง

โˆ’

Theory :- In mathematics and Signal Processing the inverse z transform converts

frequency domain signal to discrete time domain signal.

Matlab Code :-

%Determine Inverse Z transform

clc;

clear all;

close all;

b= [1+0.4*sqrt(2) 0];

a= [1-0.8*sqrt(2) 0.64];

[r,p,c]=residuez(b,a);

M=abs(p);

Q=angle(p);

Result :-

Conclusion :-

From the above experiment we get our result and itโ€™s successfully

executed.

Aim:- Given difference equation

(๐‘–๐‘–) Find ๐ป๐ป(๐‘ง๐‘ง)

(๐‘–๐‘–๐‘–๐‘–) Sketch the poles and zeros

(๐‘–๐‘–๐‘–๐‘–๐‘–๐‘–) Plot ๏ฟฝ๐ป๐ป(๐‘’๐‘’

๐‘—๐‘—๐‘—๐‘—

๐‘—๐‘—๐‘—๐‘—

(๐‘–๐‘–๐‘–๐‘–) Find โ„Ž(๐‘›๐‘›)

๐ด๐ด๐‘›๐‘›๐ด๐ด: โˆ’ Given that ๐‘ฆ๐‘ฆ

โˆ’

๐‘Œ๐‘Œ(๐‘ง๐‘ง)

๐‘‹๐‘‹(๐‘ง๐‘ง)

1

1โˆ’0.9๐‘ง๐‘ง

โˆ’

Matlab Code:-

%poles and zeros

clc;

clear all;

close all;

b=[1,0];

a=[1,-0.9];

zplane(b,a);

grid on;

(๐‘–๐‘–๐‘–๐‘–๐‘–๐‘–)

%residuez,angle,absolute

clc;

clear all;

close all;

b=[1,0];

a=[1,-0.9];

[r,p,c]=residuez(b,a);

[H,W]=freqz(b,a,100);

M= abs(H);

Q= angle(H);

Aim:- To generate DFS and IDFS function.

Theory:- The term discrete function series(DFS) is intended for use instead of

DFS where the original function is periodic defined over an infinite integral.

โˆ’๐‘—๐‘—

2๐œ‹๐œ‹๐‘›๐‘›๐œ‹๐œ‹

๐‘๐‘

๐‘๐‘โˆ’

๐‘›๐‘›=

๐‘—๐‘—

2๐œ‹๐œ‹๐‘›๐‘›๐œ‹๐œ‹

๐‘๐‘

๐‘๐‘โˆ’

๐‘›๐‘›=

Matlab Code :-

clc;

clear all;

close all;

xn = [0,1,2,3];

N = 4;

Xk = dfs(xn,N);

xn = idfs(Xk,N);

function [Xk] = dfs(xn,N)

n = [0:1:N-1]; % row vector for n

k = [0:1:N-1]; % row vector for k

WN = exp(-j2pi/N);

nk = n'*k;

WNnk = WN .^ nk; %DFS matrix

Xk = xn * WNnk;

end

function [xn] = idfs(Xk,N)

n = [0:1:N-1]; % row vector for n

k = [0:1:N-1]; % row vector for k

WN = exp(-j2pi/N);

nk = k' * n;

WNnk = WN .^(- nk); %IDFS matrix

xn = (Xk*WNnk)/N;

end

Result :-

Conclusion :-

From the above experiment we get our result and itโ€™s successfully

executed.

%N=

N = 20;

k = 0:1:N-1; % sample index

wk = 2pik/N;

zk = exp(j*wk); % samples of z

Xk = (zk)./(zk-0.7); % DFS as samples of X(z)

xn = real(idfs(Xk,N)); % IDFS

xtilde = xn'*ones(1,2);

xtilde = (xtilde(:))'; % Periodic sequence

subplot(2,2,3); stem(0:39,xtilde);axis([0,40,-0.1,1.5])

xlabel('n'); ylabel('xtilde(n)'); title('N=20')

%N=

N = 40;

k = 0:1:N-1; % sample index

wk = 2pik/N;

zk = exp(j*wk); % samples of z

Xk = (zk)./(zk-0.7); % DFS as samples of X(z)

xn = real(idfs(Xk,N)); % IDFS

xtilde = xn'*ones(1,1);

xtilde = (xtilde(:))'; % Periodic sequence

subplot(2,2,4); stem(0:39,xtilde);axis([0,40,-0.1,1.5])

xlabel('n'); ylabel('xtilde(n)'); title('N=40')

function [xn] = idfs(Xk,N)

% Computes Inverse Discrete Fourier Series

% ----------------------------------------

% [xn] = idfs(Xk,N)

% xn = One period of periodic signal over 0 <= n <= N-

% Xk = DFS coeff. array over 0 <= k <= N-

% N = Fundamental period of Xk

n = [0:1:N-1]; % row vector for n

k = [0:1:N-1]; % row vecor for k

WN = exp(-j2pi/N); % Wn factor

nk = n'*k; % creates a N by N matrix

of nk values

WNnk = WN .^ (-nk); % IDFS matrix

xn = (Xk * WNnk)/N; % row vector for IDFS

values

end

Result:-

Conclusion :-

From the above experiment we get our result and itโ€™s successfully

executed.

n1=n+1;

if(rem(n,2)~=0)

n1=n;

n=n-1;

end

y=boxcar(n1);

%LPF

b=fir1(n,wp,y);

[h,o]=freqz(b,1,256);

m=20*log10(abs(h));

subplot(221);plot(o/pi,m);

ylabel('Gain in dB-->');xlabel('(a) Normalised frequency --

');

%HPF

b=fir1(n,wp,'high',y);

[h,o]=freqz(b,1,256);

m=20*log10(abs(h));

subplot(222);plot(o/pi,m);

ylabel('Gain in dB-->');xlabel('(b) Normalised frequency --

');

%BAND PASS FILTER

wn=[wp ws];

b=fir1(n,wn,y);

[h,o]=freqz(b,1,256);

m=20*log10(abs(h));

subplot(223);plot(o/pi,m);

ylabel('Gain in dB-->');xlabel('(c) Normalised frequency --

');

%BAND STOP FILTER

b=fir1(n,wn, 'stop', y);

[h,o]=freqz(b,1,256);

m=20*log10(abs(h));

subplot(224);plot(o/pi,m);

ylabel('Gain in dB-->');xlabel('(d) Normalised frequency --

');

Result:-

Conclusion :-

From the above experiment we get our result and itโ€™s successfully

executed.

[b,a]=butter(n,wn,'high');

w=0:.01:pi;

[h,om]=freqz(b,a,w);

m=20*log10(abs(h));

an=angle(h);

subplot(423);plot(om/pi,m);

ylabel('Gain in dB-->');xlabel('(a) Normalised frequency --

');title('High Pass Filter');

subplot(424);plot(om/pi,an);

ylabel('Phase in radians-->');xlabel('(b) Normalised frequency

-->');title('High Pass Filter');

%BAND PASS FILTER

w1=2*wp/fs;

w2=2*ws/fs;

%[n]=buttord(w1,w2,rp,rs);

wn=[w1 w2];

[b,a]=butter(n,wn,'bandpass');

w=0:.01:pi;

[h,om]=freqz(b,a,w);

m=20*log10(abs(h));

an=angle(h);

subplot(425);plot(om/pi,m);

ylabel('Gain in dB-->');xlabel('(a) Normalised frequency --

');title('Band Pass Filter');

subplot(426);plot(om/pi,an);

ylabel('Phase in radians-->');xlabel('(b) Normalised frequency

-->');title('Band Pass Filter');

%BAND STOP FILTER

w1=2*wp/fs;

w2=2*ws/fs;

wn=[w1 w2];

[b,a]=butter(n,wn,'stop');

w=0:.01:pi;

[h,om]=freqz(b,a,w);

m=20*log10(abs(h));

an=angle(h);

subplot(427);plot(om/pi,m);

ylabel('Gain in dB-->');xlabel('(a) Normalised frequency --

');title('Band Stop Filter');

subplot(428);plot(om/pi,an);

ylabel('Phase in radians-->');xlabel('(b) Normalised frequency

-->');title('Band Stop Filter');

Result:-

Conclusion :-

From the above experiment we get our result and itโ€™s successfully

executed.