














Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
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
1 / 22
This page cannot be seen from the preview
Don't miss anything!















th
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.