Sunteți pe pagina 1din 74

Advanced Signal Processing Lab Report

Lab Report
Advanced Signal Processing
Submitted By

TAPAS KUMAR DASH


TRAINEE SCIENTIST,AES
PGRPE-2014
Submitted in partial fulfilment of M.Tech

UNDER THE SUPERVISION OF

DR. A. Karmakar
IC Design Group

ACSIR , CSIR-Central Electronics Engineering Research Institute


Pilani, Rajasthan
(2014-2016)
CENTRAL ELECTRONICS ENGINEERING RESEARCH INSTITUTE, PILANI, RAJASTHAN, INDIA-333 031 Page 1

Advanced Signal Processing Lab Report

Lab Assignment - I
Signal & Image Processing - I: ENG(CEERI) : 2-219
Advanced Electronic Systems
AcSIR IMP Programme
CSIR-CEERI, Pilani

CENTRAL ELECTRONICS ENGINEERING RESEARCH INSTITUTE, PILANI, RAJASTHAN, INDIA-333 031 Page 2

Advanced Signal Processing Lab Report


M-point moving average system is defined by

I.1

y[n]

1
M

M 1

x[n k ] .
k 0

Such a system is often used in smoothing random variations in data. Consider the case of a signal
s[n] is corrupted by a noise d[n] for n>=0, resulting in a measured data given by x[n] s[n] d[n] .
We would like to reduce the effect of the noise d[n] and get a better estimate of s[n] from x[n].
n
Generate the signal s[n] 2n 0.9 and plot this uncorrupted signal. Generate a realization of

(100 values) of random noise by using rand function containing pseudo-random values drawn from
a uniform distribution on the unit interval. Now, generate the corrupted signal x[n].Employ the
moving average filter for M=3 and notice the effect of the noise smoothing. Comment on delay for
this operation. Also investigate the effect of signal smoothing by the moving average filter of length
4 and higher. Comment on your results.

CODE:
assignment1_1.m
%Lab Assignment-1.1
%M-Point Moving Average Filter to smooth corrupted signal
%Submitted By
% Tapas Kumar Dash
% Trainee Scientist, PGRPE-2014
clc
clear all
close all
M=input('Enter the required M point value of Moving Average
Filter:');
out=moving_average_filter( M );
--------------------------------------------------------------

moving_average_filter.m
function [ y ] = moving_average_filter( M )
%Implementation of MOVING AVERAGE FILTER
%Such a system is used in smoothing random variations in data

CENTRAL ELECTRONICS ENGINEERING RESEARCH INSTITUTE, PILANI, RAJASTHAN, INDIA-333 031 Page 3

Advanced Signal Processing Lab Report


%***************************************************************
********
%Description of given system
n=1:100;
m=0:99;
s=2.*n.*power(0.9,n);
d=rand(1,100);

%Time Index n
%Generate the uncorrupted signal
%Generate the random noise

x=s+d;

%Generate the corrupted signal

%***************************************************************
********
%Logic Implementation of Moving Average Filter Starts from here
%***************************************************************
********
x=[zeros(1,M-1) x];
y=zeros(1,100);
for i=M:(length(x))
for j=1:M
y(i-M+1)=y(i-M+1)+x(i-j+1);
end
end
y=y/M;

%Output of Moving_Average Filter

%End of Logic here


%***************************************************************
**********
%Plotting of The Results starts here
%***************************************************************
**********
subplot(2,1,1);
plot(m,d,'r-',m,s,'g--',m,x(M:(length(x))),'b-.'),xlabel('Time
index n');ylabel('Amplitude');legend('d[n]:Random Noise
Signal','s[n]:Uncorrupted Signal','x[n]: Corrupted Signal');
grid,title('Variation of Random Noise Signal:d[n], Uncorrupted
signal:s[n]and Corrupted signal:x[n] w.r.t Time index n)');
subplot(2,1,2);
plot(m,y,'r-',m,s,'g--');
legend('y[n]: Smoothed M-point Moving Average Filter
Output','s[n]:Uncorruped Signal');
CENTRAL ELECTRONICS ENGINEERING RESEARCH INSTITUTE, PILANI, RAJASTHAN, INDIA-333 031 Page 4

Advanced Signal Processing Lab Report


xlabel('Time index n');ylabel('Amplitude');
grid,title([int2str(M),'-Point Moving Average Filter Smoothed
Output']);
%Plotting of The Results ends here
%***************************************************************
***********
End
----------------------------------------------------------------

OUTPUT:
Enter the required M point value of Moving Average Filter:3

CENTRAL ELECTRONICS ENGINEERING RESEARCH INSTITUTE, PILANI, RAJASTHAN, INDIA-333 031 Page 5

Advanced Signal Processing Lab Report


Enter the required M point value of Moving Average Filter:4

CENTRAL ELECTRONICS ENGINEERING RESEARCH INSTITUTE, PILANI, RAJASTHAN, INDIA-333 031 Page 6

Advanced Signal Processing Lab Report


Enter the required M point value of Moving Average Filter:10

Comments:
1. For M=3,4, and higher order(M=10),M-point moving average system
output were found out.
2. It is observed that for higher order M-Point averaging system the noise
smoothing is more.

CENTRAL ELECTRONICS ENGINEERING RESEARCH INSTITUTE, PILANI, RAJASTHAN, INDIA-333 031 Page 7

Advanced Signal Processing Lab Report


The median filter is often used for smoothing for signals corrupted by impulse noise. It is

I.2

implemented by sliding a window of one length over the input sequence x[n] one sample time. At
the nth instant, the input samples inside the window are rank ordered from the largest to the
smallest in values, and the sample at the middle is the median value. The output y[n] of the median
filter is then given

y[n] med x[n K ],..., x[n 1], x[n], x[n 1],...x[n K ].


For example, med 2, 3,10,5, 1 2. Is the median filter a linear or nonlinear discrete-time
system ? Is it time-invariant? Justify your answer through some MATLAB experimentations.

CODE:
assignment1_2.m
%Lab Assignment-1.2
%Median Filter to smooth corrupted signal
%Submitted By
% Tapas Kumar Dash
% Trainee Scientist, PGRPE-2014
clc
clear all
close all
k=7;
%***************************************************************
********
%Description of given system

m=0:1:99;

%Time Index n

x=zeros(1,100);
s=zeros(1,100);
for i=1:100
s(i)=2*(i-1)*((.9).^(i-1)); %Generate the uncorrupted signal
CENTRAL ELECTRONICS ENGINEERING RESEARCH INSTITUTE, PILANI, RAJASTHAN, INDIA-333 031 Page 8

Advanced Signal Processing Lab Report


end
d=rand(1,100);

%Generate the random noise

x=s+d;

%Generate the corrupted signal

%***************************************************************
********
y=median_filter(k,x);
%***************************************************************
********
%***************************************************************
**********
%Plotting of The Results starts here
%***************************************************************
**********
subplot(2,1,1);
plot(m,d,'r-',m,s,'g--',m,x,'b-.'),xlabel('Time index
n');ylabel('Amplitude');legend('d[n]:Random Noise
Signal','s[n]:Uncorrupted Signal','x[n]: Corrupted Signal');
grid,title('Variation of Random Noise Signal:d[n], Uncorrupted
signal:s[n]and Corrupted signal:x[n] w.r.t Time index n)');
subplot(2,1,2);
plot(m,y,'r-',m,s,'g--',m,x,'b-.');
legend('y[n]: Smoothed Median Filter Output','s[n]:Uncorruped
Signal','x[n]: Corrupted Signal');
xlabel('Time index n');ylabel('Amplitude');
grid,title('Median Filter Smoothed Output');
%Plotting of The Results ends here
%***************************************************************
***********

median_filter.m
function [ y ] = median_filter( k,x)
%MEDIAN_FILTER is used to smooth the corrupted signal

y=zeros(1,100);
%***************************************************************
********
%Logic Implementation of Median Filter Starts from here
CENTRAL ELECTRONICS ENGINEERING RESEARCH INSTITUTE, PILANI, RAJASTHAN, INDIA-333 031 Page 9

Advanced Signal Processing Lab Report


%***************************************************************
********
for i=4:(length(x)-3)
w= x((i-3):(i+3));
w=piecewise_sorting(w);
y(i)=w((k+1)/2);
end
%End of Logic here
end

piecewise_sorting.m
function [ w ] = piecewise_sorting( x )
%PIECEWISE_SORTING sorts the input vector piecewise
for i=1:length(x)
for j=1:i-1
if x(j)>x(j+1)
tmp=x(j);
x(j)=x(j+1);
x(j+1)=tmp;
end
end
end
w=x;
end

linearity_time_invariance_check.m
clear all;
close all;
clc
k=7;
x1=[1 4 8 2 3 9 0 0 8 9 0 9 8];
x2=[8 0 2 4 1 3 7 0 8 9 0 9 8];
m1=median_filter(7,x1);
m2=median_filter(7,x2);
x3=3.*x1+5.*x2;
m3=median_filter(7,x3);
if(m3==3*m1+5*m2)
disp('filter is linear');
else
disp('filter is non-linear');
CENTRAL ELECTRONICS ENGINEERING RESEARCH INSTITUTE, PILANI, RAJASTHAN, INDIA-333 031 Page 10

Advanced Signal Processing Lab Report


end
D=10;
x4=[zeros(1,D) 1 4 8 2 3 9 0 0 8 9 0 9 8];
m4=median_filter(7,x4);
m5=[zeros(1,3) m4(1+(D+3):length(m4)) zeros(1,D)];
if(m1==m5)
disp('filter is Time Invariant');
else
disp('filter is Time Variant');
end

Comment:

Median filter is non-linear and tine invariant filter.


Filter is non-linear.
As compared to averaging filter median filter is preferred.

PLOT:

CENTRAL ELECTRONICS ENGINEERING RESEARCH INSTITUTE, PILANI, RAJASTHAN, INDIA-333 031 Page 11

Advanced Signal Processing Lab Report


Consider the discrete-time system characterized by the input-output relation

I.3

1
x[n]
y[n] y[n 1]

2
y[n 1]
where x[n] and y[n] are , respectively, the input and output sequences. Show that the output y[n] of
the above system for an input x[n] nu[n] with y[1] 1 converges to

as n when is

a positive number. Is the above system linear or non-linear ? Is it time-invariant ? Justify your
answer.
Implement the above system in MATLAB and show that output y[n] of the above system for an
input x[n] nu[n] with y[1] 1 converges to

as n .

CODE
assignment1_3.m
%Lab Assignment-1.3
%Submitted By
% Tapas Kumar Dash
% Trainee Scientist, PGRPE-2014
close all;
clear all;
clc
alpha= input('Enter values of Alpha:');
u=ones(1,100);
n=1:100;
for i=1:length(alpha)
x=alpha(i)*u;
out=output_discrete_system(x);
plot(n,out,'DisplayName',['alpha=',num2str(alpha(i))]),legend('DynamicLegend'),hold all;
end
output_discrete_system.m
CENTRAL ELECTRONICS ENGINEERING RESEARCH INSTITUTE, PILANI, RAJASTHAN, INDIA-333 031 Page 12

Advanced Signal Processing Lab Report


function [ out] = output_discrete_system(x)
%OUTPUT_DISCRETE_SYSTEM Summary of this function goes here
%
Detailed explanation goes here
y(1)=1;
for n=2:100
y(n)=(y(n-1)+(x(n)/y(n-1)))/2;
end
out=y;
end

OUTPUT:
Enter values of Alpha:[ 0.25 0.5 2 5 8];

CENTRAL ELECTRONICS ENGINEERING RESEARCH INSTITUTE, PILANI, RAJASTHAN, INDIA-333 031 Page 13

Advanced Signal Processing Lab Report


The linear convolution of two sequences x[n] and h[n] is defined by y[n] h[n] x[n] . The

I.4

process of recovering x[n] knowing y[n] is called deconvolution. A recursive algorithm for
deconvolution can be developed from a sequence obtained by a convolution of two finite-length
sequences. Let the lengths of x[n] and h[n] be N and M, respectively. Show that x[n] can be
computed recursively for 0 n N 1 from h[n] and the first N samples of y[n] by a linear
constant coefficient difference equation. Now consider the following cases,
a)

y[n] 2,8, 20, 40,60,68,62, 40 h[n] 2, 4,6,8

b)

y[n] 3,8, 20,10, 12,12,16, 58,35 , h[n] 1, 2, 4, 4,5

Determine x[n] for the above. The first sample in each sequence is its value at n=0.
The deconvolution operation as defined above can be performed using MATLAB. Employ the
appropriate MATLAB function and the obtain x[n] for the two cases. Compare your results.

CODE:
assignment1_4.m
%Lab Assignment-1.4
%Submitted By
% Tapas Kumar Dash
% Trainee Scientist, PGRPE-2014
%Deconvolution
clear all
close all
clc
y1=[2 8 20 40 60 68 62 40];
h1=[2 4 6 8];
x1=deconv(y1,h1);
disp(x1);
x2=deconvolution(y1,h1);
disp(x2);
x3=x2(1:length(y1)-length(h1)+1);
disp(x3);
if(x1==int64(x3))

CENTRAL ELECTRONICS ENGINEERING RESEARCH INSTITUTE, PILANI, RAJASTHAN, INDIA-333 031 Page 14

Advanced Signal Processing Lab Report


disp('For 1st question Deconvolution obtained from User
defined function is same as obtained by InBuilt Function
deconv()');
else
disp('For 1st question Deconvolution obtained from User defined
function is different from result obtained by InBuilt Function
deconv()');
end
y2=[-3 8 -20 10 -12 12 16 -58 35];
h2=[-1 2 -4 4 5];
x4=deconv(y2,h2);
disp(x4);
x5=deconvolution(y2,h2);
x6=int64(x5(1:length(y2)-length(h2)+1));
disp(x6);
if(x4==x6)
disp('For 2nd question Deconvolution obtained from User
defined function is same as obtained by InBuilt Function
deconv()');
else
disp('For 2nd question Deconvolution obtained from User defined
function is different from result obtained by InBuilt Function
deconv()');
end

deconvolution.m
function [ out ] = deconvolution( y,h )
[mb,nb] = size(y);
nb = max(mb,nb);
na = length(h);
% Deconvolution and polynomial division are the same
operations
% as a digital filter's impulse response B(z)/A(z):
q = filter(y, h,[1 zeros(1,nb-na)]);
out=q;
end
CENTRAL ELECTRONICS ENGINEERING RESEARCH INSTITUTE, PILANI, RAJASTHAN, INDIA-333 031 Page 15

Advanced Signal Processing Lab Report


OUTPUT:
X1=1

X1= 1

For 1st question Deconvolution obtained from User defined function is same as obtained by InBuilt
Function deconv()
X2=3 -2

4 18 39

X2=3 -2

4 18 39

For 2nd question Deconvolution obtained from User defined function is same as obtained by InBuilt
Function deconv()
I.5

Obtain the discrete-time Fourier transform of each of the following sequences.

1 N n N
0 otherwise

a) y1[n]

1 n / N , N n N
otherwise

b) y2 [n]

cos( n / 2 N ), N n N
otherwise
0,

c) y2 [n]

Plot the real and imaginary parts and the magnitude and phase spectra of the DTFTs. Comment on
the result.

CODE:
assignment1_5.m
%Lab Assignment-1.5
%DTFT of the given sequences
%Submitted By
CENTRAL ELECTRONICS ENGINEERING RESEARCH INSTITUTE, PILANI, RAJASTHAN, INDIA-333 031 Page 16

Advanced Signal Processing Lab Report


% Tapas Kumar Dash
% Trainee Scientist, PGRPE-2014
clc
clear all
close all
%***************************************************************
********
% Generate given 3 sequences
%***************************************************************
********
n=-40:40;

%Time Index n

N=input('enter the value for N:');


% Generate 1st Input Sequence
x1=[zeros(1,(40-N)),ones(1,2*N+1),zeros(1,(40-N))];
% Generate 2nd Input sequence
for j=-N:N
temp(j+N+1)=1-abs(j)/N;
end
x2=[zeros(1,(40-N)),temp,zeros(1,(40-N))];
% Generate 3rd Input sequence
for j=-N:N
temp1(j+N+1)=cos(pi*j/2*N);
end
x3=[zeros(1,(40-N)),temp1,zeros(1,(40-N))];
%***************************************************************
********
% To obtain the discrete time fourier transform
% user defined function discrete_fourier_transform(x) called
%***************************************************************
********
y1=discrete_fourier_transform(x1);
y2=discrete_fourier_transform(x2);
y3=discrete_fourier_transform(x3);

CENTRAL ELECTRONICS ENGINEERING RESEARCH INSTITUTE, PILANI, RAJASTHAN, INDIA-333 031 Page 17

Advanced Signal Processing Lab Report


%***************************************************************
********
% Plot real and imaginary parts and the magnitude and phase
spectra of
% the DTFTs
%***************************************************************
********
w=-pi:pi/40:pi;
figure(1),plot_figure(y1,x1,w,1);
figure(2),plot_figure(y2,x2,w,2);
figure(3),plot_figure(y3,x3,w,3);
%***************************************************************
*********

discrete_fourier_transform.m
function [ out ] = discrete_fourier_transform( x )
%DISCRETE_FOURIER_TRANSFORM Summary of this function goes here
%
Detailed explanation goes here
k=1;
for w=-pi:pi/40:pi
y(1)=0;
for i=2:length(x)+1
y(i)=x(i-1)*exp(-1i*w*(i-2))+y(i-1);
end
out(k)=sum(y);
k=k+1;
end
end

plot_figure.m
function [ output_args ] = plot_figure( y,x,w,i )
%PLOT_FIGURE Summary of this function goes here
%
Detailed explanation goes here
n=-40:40;
subplot(2,2,1),stem(n,x),grid,title(['Input
Sequence',int2str(i)]);
subplot(2,2,2),plot(w./pi,real(y),'b',w,imag(y),'r'),grid,title(
['DTFT of Input Sequence-',int2str(i)]);
subplot(2,2,3),plot(w./pi,abs(y)),grid,title(['Magnitude
spectrum of DTFT of Input Sequence-',int2str(i)]);
CENTRAL ELECTRONICS ENGINEERING RESEARCH INSTITUTE, PILANI, RAJASTHAN, INDIA-333 031 Page 18

Advanced Signal Processing Lab Report


subplot(2,2,4),plot(w./pi,angle(y)),grid,title(['Phase spectrum
of DTFT of input sequence-',int2str(i)]);
end

OUTPUT:
enter the value for N:5

CENTRAL ELECTRONICS ENGINEERING RESEARCH INSTITUTE, PILANI, RAJASTHAN, INDIA-333 031 Page 19

Advanced Signal Processing Lab Report

I.6

Determine and plot the real and imaginary parts, and the magnitude and phase spectra of
the following DTFTs
a) G(e j )

1
for(i) r 0.9 0.75 and (ii) r 0.7 0.5
1 2r (cos )e j r 2e j 2

1 3e j 3e j 2 e j 3
b) X (e )
0.0736 0.0718e j 0.0631e j 2 0.0214e j 3
j

CODE
assignment1_6.m
%Lab Assignment-1.6
%Plot the real and imaginary parts, and the magnitude and phase
spectra of
%DTFTs
%Submitted By
% Tapas Kumar Dash
% Trainee Scientist, PGRPE-2014
clc
clear all
close all
CENTRAL ELECTRONICS ENGINEERING RESEARCH INSTITUTE, PILANI, RAJASTHAN, INDIA-333 031 Page 20

Advanced Signal Processing Lab Report


%1.6. a) i. for r=0.9 theta=0.75
r=0.9;
theta=0.75;
m=1;
for w=-pi:pi/80:pi
G1(m)=1/(1-(2*r*cos(theta)*exp(-1i*w))+r*r*exp(-1i*2*w));
m=m+1;
end
%1.6. a) ii. for r=0.7 theta=0.5
r=0.7;
theta=0.5;
m=1;
for w=-pi:pi/80:pi
G2(m)=1/(1-(2*r*cos(theta)*exp(-1i*w))+r*r*exp(-1i*2*w));
m=m+1;
end
%1.6. b)
n=1;
for w=-pi:pi/80:pi
X(n)=(1+3*exp(-1i*w)+3*exp(-1i*2*w)+exp(-1i*3*w))/(0.07360.0718*exp(-1i*w)+0.0631*exp(-1i*2*w)+0.0214*exp(-1i*3*w));
n=n+1;
end
w=-pi:pi/80:pi;
figure(1),plot_figure_6(G1,w);
figure(2),plot_figure_6(G2,w);
figure(3),plot_figure_6(X,w);

plot_figure_6.m
function [ out ] = plot_figure_6( G,w )
%PLOT_FIGURE_6 Summary of this function goes here
%
Detailed explanation goes here
out=G;
CENTRAL ELECTRONICS ENGINEERING RESEARCH INSTITUTE, PILANI, RAJASTHAN, INDIA-333 031 Page 21

Advanced Signal Processing Lab Report


subplot(2,2,1),plot(w./pi,real(G)),grid,title('Real part');
subplot(2,2,2),plot(w./pi,imag(G)),grid,title('Imaginary part');
subplot(2,2,3),plot(w./pi,abs(G)),grid,title('Magnitude
Spectrum');
subplot(2,2,4),plot(w./pi,angle(G)),grid,title('Phase
spectrum');
end
OUTPUT:

CENTRAL ELECTRONICS ENGINEERING RESEARCH INSTITUTE, PILANI, RAJASTHAN, INDIA-333 031 Page 22

Advanced Signal Processing Lab Report

I.7

Using MATLAB determine the factored form of the following z-transform

2 z 4 16 z 3 44 z 2 56 z 32
a) G1 ( z )
3z 4 3z 3 15 z 2 18 z 12
b) G2 ( z )

4 z 4 8.68 z 3 17.98 z 2 26.74 z 8.04


z 4 2 z 3 10 z 2 6 z 65

and show their pole-zero plots. Determine all regions of convergence (ROCs) of each of the above ztransforms, and describe the type of their inverse z-transforms (left-sided, right-sided, two-sided
sequences) associated with each of the ROCs.

CODE:
assignment1_7.m
%Lab Assignment-1.7
%Determine Factored form of given Z-transform
%Plot its pole-zero plot
%Submitted By
% Tapas Kumar Dash
% Trainee Scientist, PGRPE-2014

CENTRAL ELECTRONICS ENGINEERING RESEARCH INSTITUTE, PILANI, RAJASTHAN, INDIA-333 031 Page 23

Advanced Signal Processing Lab Report


num1=input('enter numerator:');
den1=input('enter denominator:');
zeros1=roots(num1);
poles1=roots(den1);
no_zero2=length(zeros1);
no_pole2=length(poles1);
str1='';
str2='';
for i=1:no_zero2
str1=strcat(str1,'(z-','(',num2str(zeros1(i)),')',')');
end
for i=1:no_pole2
str2=strcat(str2,'(z-','(',num2str(poles1(i)),')',')');
end
sprintf('\t%s\nG=\t------------------------------------------------\n\t%s',str1,str2)
H2=filt(num1,den1);
figure,pzmap(H2);

OUTPUT
enter numerator:[2 16 44 56 32]
enter denominator:[3 3 -15 18 -12]
ans =
(z-(-4))(z-(-2))(z-(-1+1i))(z-(-1-1i))
G=

------------------------------------------------(z-(-3.2361))(z-(1.2361))(z-(0.5+0.86603i))(z-(0.5-0.86603i))

b)
CENTRAL ELECTRONICS ENGINEERING RESEARCH INSTITUTE, PILANI, RAJASTHAN, INDIA-333 031 Page 24

Advanced Signal Processing Lab Report


enter numerator:[4 -8.68 -17.98 26.74 -8.04]
enter denominator:[1 -2 10 6 65]
ans =
(z-(3))(z-(-2))(z-(0.67))(z-(0.5))
G=

------------------------------------------------(z-(2+3i))(z-(2-3i))(z-(-1+2i))(z-(-1-2i))

Power Complementary

I.8

The L transfer functions Hi (e j ) 0 i L 1 are called power complementary if


L 1

H (e )
j

i 0

1.

Through analytic continuation, we find the equivalent relation in z-transform (on unit circle)
L 1

H ( z)H ( z
i 0

) 1

(Try to prove it, analytically. Hint : Use Z-transform Properties)

Note: For two transfer functions H 0 ( z ) and H1 ( z ) the relationship is,

H 0 ( z) H 0 ( z 1 ) H1 ( z) H1 ( z 1 ) 1

CENTRAL ELECTRONICS ENGINEERING RESEARCH INSTITUTE, PILANI, RAJASTHAN, INDIA-333 031 Page 25

Advanced Signal Processing Lab Report


Now show that for each case listed below, H(z) and H(-z) are power-complementary
a) H ( z )

0.75 z 1 2 z 2 2 z 3 z 4 0.75 z 5
3 3.5 z 2 z 4

b) H ( z )

1 1.5 z 1 3.75 z 2 2.75 z 3 2.75 z 4 3.75z 5 1.55z 6 z 7


6 6.5 z 2 4.5 z 4 z 6

To verify the power complementary property, write MATLAB program to evaluate

H ( z) H ( z 1 ) H ( z ) H ( z 1 ) and show that this expression is equal to unity for each of


the transfer functions given above.

CODE:
assignment1_8.m
%Lab Assignment-1.8
%verification of power complementary function
%Submitted By
% Tapas Kumar Dash
% Trainee Scientist, PGRPE-2014
clear all;
close all;
clc
w=2*pi;
b=input('enter numerator:');
a=input('enter denominator:');
[Z,p,k]=tf2zpk(b,a);
np=poly(Z);
dp=poly(p);
%H(z)
z=exp(1i*w);
num=polyval(np,z);
den=polyval(dp,z);
h1=k*(num./den);
%H(z^-1)
z1=exp(-1i*w);
num1=polyval(np,z1);
den1=polyval(dp,z1);
h2=k*(num1./den1);
%H(z)*H(z^-1)
h3=h1.*h2;
%H(-z)
z2=-exp(1i*w);
num2=polyval(np,z2);
den2=polyval(dp,z2);
h4=k*(num2./den2);
%H(-z^-1)
z3=-exp(-1i*w);
num3=polyval(np,z3);

CENTRAL ELECTRONICS ENGINEERING RESEARCH INSTITUTE, PILANI, RAJASTHAN, INDIA-333 031 Page 26

Advanced Signal Processing Lab Report


den3=polyval(dp,z3);
h5=k*(num3./den3);
%H(-z)*H(-z^-1)
h6=h4.*h5;
%H(z)*H(z^-1)+H(-z)*H(-z^-1)
h7=h3+h6;
disp(sum(h7));

OUTPUT:
a)
>>enter numerator:[0 0.75 2 2 1 0.75]
enter denominator:[3 0 3.5 0 1]

0.755555555555554
b)
>>enter numerator:[1 -1.5 3.75 -2.75 2.75 -3.75 1.55 -1]
enter denominator:[6 0 6.5 0 4.5 0 1]
1.005570987654322

I.9

Look at the following third-order IIR transfer function,

z 1 (1 z 1 )2
H ( z)
(1 0.4 z 1 )(1 0.88 z 1 0.61z 2 )
Using MATLAB determine and plot its gain reponses and show that it has a highpass response.

CODE:
assignment1_9.m
%Lab Assignment-1.9
%Submitted By
% Tapas Kumar Dash
% Trainee Scientist, PGRPE-2014

clear all;
close all;
clc

CENTRAL ELECTRONICS ENGINEERING RESEARCH INSTITUTE, PILANI, RAJASTHAN, INDIA-333 031 Page 27

Advanced Signal Processing Lab Report


w=0:pi/100:2*pi;
Z=input('enter zeros:');
p=input('enter poles:');
np=poly(Z);
dp=poly(p);
z=exp(1i*w);
num=polyval(np,z);
den=polyval(dp,z);
h1=num./den;
subplot(2,1,1),zplane(Z,p),grid,title('pole-zero plot');
subplot(2,1,2),plot(w,20*log10(abs(h1))),grid,title('Magnitude plot');
num=polyval(np,z);
den=polyval(dp,z);
h1=num./den;
subplot(2,1,1),zplane(Z,p),grid,title('pole-zero plot');
subplot(2,1,2),plot(w,20*log10(abs(h1))),grid,title('Magnitude plot');

Output:
>>
enter zeros:[0;1;1]
enter poles:[0.4;0.44+0.6453i;0.44-0.6543i]

CENTRAL ELECTRONICS ENGINEERING RESEARCH INSTITUTE, PILANI, RAJASTHAN, INDIA-333 031 Page 28

Advanced Signal Processing Lab Report

Lab Assignment II
Lab: Signal & Image Processing- I: ENG (CEERI): 2-219
Advanced Electronic Systems
AcSIR IMP Programme
CSIR-CEERI, Pilani

CENTRAL ELECTRONICS ENGINEERING RESEARCH INSTITUTE, PILANI, RAJASTHAN, INDIA-333 031 Page 29

Advanced Signal Processing Lab Report


II.1 Consider distorting function to be
=

Show the plots pole-zero, log magnitude, phase, and group delay for Hd(ejw) and comment on
stability, causality and also on whether the system is minimum phase .

CODE:
test_1.m
%
%
%
%
%
%

%Lab Assignment-1
%Author:TAPAS KUMAR DASH
%Trainee Scientist,PGRPE-2014
Show the plots pole-zero, log magnitude, phase, and group delay for
distorting function Hd(ejw) and comment on stability, causality and
also on whether the system is minimum phase

clc
clear all
close all
zero=[0.9*exp(0.6j*pi) 0.9*exp(-0.6j*pi) 1.25*exp(0.8j*pi) 1.25*exp(0.8j*pi)];
pole=[0 0 0 0];
[Hmag,Hang,w]=freq_response(pole,zero,'PZ');
num=poly(zero);
den=poly(pole);
hd=filt(num,den);%Transfer function
figure(1),
subplot(2,2,1)
plot(w/pi,Hmag);
xlabel('frequency(xPi)');
title('log magnitude');
subplot(2,2,3)
plot(w/pi,Hang);
xlabel('frequency(xPi)');
title('phase');
subplot(2,2,2)
pzmap(hd);
title('pole zero plot');
[grpdel,w]=group_delay_calculation(pole,zero,'PZ');
subplot(2,2,4)
plot(w,grpdel);
title('group delay');
res1=verify_stability(zero,pole);

CENTRAL ELECTRONICS ENGINEERING RESEARCH INSTITUTE, PILANI, RAJASTHAN, INDIA-333 031 Page 30

Advanced Signal Processing Lab Report


str1='';
if res1==1
str1=strcat(str1,'System is: stable');
else
str1=strcat(str1,'System is: unstable');
end
res2=verify_causality(zero,pole);
if res2==1
str1=strcat(str1,' causal');
else
str1=strcat(str1,'non-causal');
end
res3=verify_minimumphasesystem_pz(zero,pole);
if res3==1
str1=strcat(str1,' minimum phase');
else
str1=strcat(str1,'non-minimum phase');
end
disp(str1);

freq_response.m
function [ Hmag,Hang,w ] =
freq_response(Pole_or_Denominator,Zero_or_Numerator,TYPE )
%Function has 3 arguments:: 1-Pole_or_Denominator
%
2-Zero_or_Numerator
%
3-TYPE
%Argument TYPE denotes whether input arguments are in pole zero form(if
%TYPE='PZ') or numerator and denominator form(if TYPE='ND')
if strcmp(TYPE,'PZ')
denominator=poly(Pole_or_Denominator);
numerator=poly(Zero_or_Numerator);
elseif strcmp(TYPE,'ND')
denominator=Pole_or_Denominator;
numerator=Zero_or_Numerator;
end
denominator_length=length(denominator);
numerator_length=length(numerator);
Hmag_numerator=zeros(1,101);
Hmag_denominator=zeros(1,101);
k=1;
for w=-pi:pi/50:pi
for m=0:numerator_length-1
Hmag_numerator(k)=Hmag_numerator(k)+numerator(m+1)*exp(-m*1j*w);
end
k=k+1;
end

CENTRAL ELECTRONICS ENGINEERING RESEARCH INSTITUTE, PILANI, RAJASTHAN, INDIA-333 031 Page 31

Advanced Signal Processing Lab Report


k=1;
for w=-pi:pi/50:pi
for m=0:denominator_length-1
Hmag_denominator(k)=Hmag_denominator(k)+denominator(m+1)*exp(m*1j*w);
end
k=k+1;
end
hmag=abs(Hmag_numerator)./abs(Hmag_denominator);
Hmag=20*log10(hmag);
Hang=angle(Hmag_numerator)-angle(Hmag_denominator);
w=-pi:pi/50:pi;

end

group_delay_calculation.m
function [ group_delay,w ] = group_delay_calculation(
Zero_or_Numerator,Pole_or_Denominator,TYPE )
%This function performs group delay calculation

if strcmp(TYPE,'PZ')
denominator=poly(Pole_or_Denominator);
numerator=poly(Zero_or_Numerator);
elseif strcmp(TYPE,'ND')
denominator=Pole_or_Denominator;
numerator=Zero_or_Numerator;
end
denominator_length=length(denominator);
numerator_length=length(numerator);
Hmag_numerator=zeros(1,101);
Hmag_denominator=zeros(1,101);
k=1;
for w=-pi:pi/50:pi
for m=0:numerator_length-1
Hmag_numerator(k)=Hmag_numerator(k)+numerator(m+1)*exp(-m*1j*w);
end
k=k+1;
end
k=1;
for w=-pi:pi/50:pi
for m=0:denominator_length-1
Hmag_denominator(k)=Hmag_denominator(k)+denominator(m+1)*exp(m*1j*w);
end
k=k+1;

CENTRAL ELECTRONICS ENGINEERING RESEARCH INSTITUTE, PILANI, RAJASTHAN, INDIA-333 031 Page 32

Advanced Signal Processing Lab Report


end
Hang=angle(Hmag_numerator)-angle(Hmag_denominator);
w=-pi:pi/50:pi;
for k=1:length(Hang)
if k-1>0
group_delay(k)=-((50/pi)*(Hang(k)-Hang(k-1)));
else
group_delay(k)=0;
end
end
end

verify_stability.m
function [res] =verify_stability(zero,pole)
%If all the poles are inside unit circle then system is stable
if max(abs(pole))<1
res=1; %Stable
else
res=0;
end
end

verify_causality.m
function [res] = verify_causality(zero,pole)
if max(abs(pole))==0
res=1;
else
res=0;
end
end

verify_minimumphasesystem_pz.m
function [res] = verify_minimumphasesystem_pz(zero,pole)
pole_mag=abs(pole);
zero_mag=abs(zero);
if max(pole_mag)<1 && max(zero_mag)<1
res=1;
else
res=0;
end
end

CENTRAL ELECTRONICS ENGINEERING RESEARCH INSTITUTE, PILANI, RAJASTHAN, INDIA-333 031 Page 33

Advanced Signal Processing Lab Report

OUTPUT:

Comment:
System is: stable causal and non-minimum phase system

II.2 Plot the log magnitude, phase and group delay for a second order all-pass system with poles at
z =0.9e-j/4 and z=0.9ej/4.

CODE:
CENTRAL ELECTRONICS ENGINEERING RESEARCH INSTITUTE, PILANI, RAJASTHAN, INDIA-333 031 Page 34

Advanced Signal Processing Lab Report


test_2.m
%
%
%
%
%

%Lab Assignment-2
%Author:TAPAS KUMAR DASH
%Trainee Scientist,PGRPE-2014
Plot the log magnitude, phase and group delay for a second order
all-pass system with poles at z =0.9e-j?/4 and z=0.9ej?/4.

clc
clear all
close all
pole=[0.9*exp(-1j*pi/4) 0.9*exp(1j*pi/4)];
%Zeros are conjugate inverse of poles
zero=[1.1111*exp(1j*pi/4) 1.1111*exp(-1j*pi/4)];
[Hmag,Hang,w]=freq_response(pole,zero,'PZ');
num=poly(zero);
den=poly(pole);
hd=filt(num,den);%Transfer function
figure(1),
subplot(2,2,1)
plot(w/pi,Hmag);
xlabel('frequency(xPi)');
title('log magnitude');
subplot(2,2,3)
plot(w/pi,Hang);
xlabel('frequency(xPi)');
title('phase');
subplot(2,2,2)
pzmap(hd);
title('pole zero plot');
[grpdel,w]=group_delay_calculation(pole,zero,'PZ');
subplot(2,2,4)
plot(w,grpdel);
title('group delay');

freq_response.m
function [ Hmag,Hang,w ] =
freq_response(Pole_or_Denominator,Zero_or_Numerator,TYPE )
%Function has 3 arguments:: 1-Pole_or_Denominator
%
2-Zero_or_Numerator
%
3-TYPE
%Argument TYPE denotes whether input arguments are in pole zero form(if
%TYPE='PZ') or numerator and denominator form(if TYPE='ND')
if strcmp(TYPE,'PZ')
denominator=poly(Pole_or_Denominator);
numerator=poly(Zero_or_Numerator);
elseif strcmp(TYPE,'ND')
denominator=Pole_or_Denominator;
numerator=Zero_or_Numerator;

CENTRAL ELECTRONICS ENGINEERING RESEARCH INSTITUTE, PILANI, RAJASTHAN, INDIA-333 031 Page 35

Advanced Signal Processing Lab Report


end
denominator_length=length(denominator);
numerator_length=length(numerator);
Hmag_numerator=zeros(1,101);
Hmag_denominator=zeros(1,101);
k=1;
for w=-pi:pi/50:pi
for m=0:numerator_length-1
Hmag_numerator(k)=Hmag_numerator(k)+numerator(m+1)*exp(-m*1j*w);
end
k=k+1;
end
k=1;
for w=-pi:pi/50:pi
for m=0:denominator_length-1
Hmag_denominator(k)=Hmag_denominator(k)+denominator(m+1)*exp(m*1j*w);
end
k=k+1;
end
hmag=abs(Hmag_numerator)./abs(Hmag_denominator);
Hmag=20*log10(hmag);
Hang=angle(Hmag_numerator)-angle(Hmag_denominator);
w=-pi:pi/50:pi;

end

group_delay_calculation.m
function [ group_delay,w ] = group_delay_calculation(
Zero_or_Numerator,Pole_or_Denominator,TYPE )
%This function performs group delay calculation

if strcmp(TYPE,'PZ')
denominator=poly(Pole_or_Denominator);
numerator=poly(Zero_or_Numerator);
elseif strcmp(TYPE,'ND')
denominator=Pole_or_Denominator;
numerator=Zero_or_Numerator;
end
denominator_length=length(denominator);
numerator_length=length(numerator);
Hmag_numerator=zeros(1,101);
Hmag_denominator=zeros(1,101);
k=1;
for w=-pi:pi/50:pi

CENTRAL ELECTRONICS ENGINEERING RESEARCH INSTITUTE, PILANI, RAJASTHAN, INDIA-333 031 Page 36

Advanced Signal Processing Lab Report


for m=0:numerator_length-1
Hmag_numerator(k)=Hmag_numerator(k)+numerator(m+1)*exp(-m*1j*w);
end
k=k+1;
end
k=1;
for w=-pi:pi/50:pi
for m=0:denominator_length-1
Hmag_denominator(k)=Hmag_denominator(k)+denominator(m+1)*exp(m*1j*w);
end
k=k+1;
end
Hang=angle(Hmag_numerator)-angle(Hmag_denominator);
w=-pi:pi/50:pi;
for k=1:length(Hang)
if k-1>0
group_delay(k)=-((50/pi)*(Hang(k)-Hang(k-1)));
else
group_delay(k)=0;
end
end
end

OUTPUT:

II.3 Consider the equations


H(z) = Hmin(z)Huc(z)Hmax(z);

and

Hmax(z) = Hmin(z-1)z-Mi
Consider the minimum phase function

= .

( .

)( .

)( .

)( .

CENTRAL ELECTRONICS ENGINEERING RESEARCH INSTITUTE, PILANI, RAJASTHAN, INDIA-333 031 Page 37

Advanced Signal Processing Lab Report


By using above equations and the minimum phase function design a linear phase system and plot
the log magnitude, phase and group delay.

Code:
test_3.m
% % %Lab Assignment-3
% % %Author:TAPAS KUMAR DASH
% % %Trainee Scientist,PGRPE-2014
%
Consider the equations
%
H(z) = Hmin(z)Huc(z)Hmax(z);
and
%
%
Hmax(z) = Hmin(z-1)z-Mi
%
%
Consider the minimum phase function
%
%
H_min (z)=?1.25?^2 (1-0.9e^j0.6? z^(-1) )
%
(1-0.9e^(-j0.6?) z^(-1) )(1-0.8e^(-j0.8?) z^(-1) )(10.8e^j0.8? z^(-1) )
%
%
By using above equations and the minimum phase function design a
%linear phase system and plot the log magnitude, phase and group delay.
clc
clear all
close all
k=1.25*1.25;
zero=[0.9*exp(1j*0.6*pi); 0.9*exp(-1j*0.6*pi); 0.8*exp(-1j*0.8*pi);
0.8*exp(1j*0.8*pi)];
pole=[];
figure,frequency_response(zero,pole,k);%minimum phase system
zero=[1.11*exp(1i*0.6*pi);1.11*exp(-1i*0.6*pi);1.25*exp(1i*0.8*pi);1.25*exp(1i*0.8*pi)];
pole=[];
k=0.9*0.9;
figure,frequency_response(zero,pole,k);%maximum phase system
zero=[1.11*exp(1i*0.6*pi);1.11*exp(1i*0.6*pi);1.25*exp(1i*0.8*pi);1.25*exp(1i*0.8*pi);0.9*exp(1i*0.6*pi);0.9*exp(1i*0.6*pi);0.8*exp(1i*0.8*pi);0.8*exp(-1i*0.8*pi)];
pole=[];
k=1.2656;
figure,frequency_response(zero,pole,k);%linear phase system

frequency_response.m
function [ y ] = frequency_response(Z,p,k)
%FREQUENCY_RESPONSE Summary of this function goes here
%Frequncy Response of a filter given poles and zeros
w=0:pi/100:2*pi;
z=exp(1i*w);

CENTRAL ELECTRONICS ENGINEERING RESEARCH INSTITUTE, PILANI, RAJASTHAN, INDIA-333 031 Page 38

Advanced Signal Processing Lab Report


np=poly(Z);
dp=poly(p);
numer=polyval(np,z);
denom=polyval(dp,z);
h=k*(numer./denom);
theta=atan2(imag(h),real(h));
%pole zero plot
subplot(2,2,1),zplane(Z,p),grid,title('Pole-Zero plot');
%magnitude plot
subplot(2,2,2),plot(w,20*log10(abs(h))),grid,title('Magnitude plot(dB)');
%Phase plot
subplot(2,2,3),plot(w,theta),grid,title('Phase plot');
%Group delay plot
[gd,w1]=grpdelay(np,dp,1024,'whole');
subplot(2,2,4),plot(w1,gd),grid,title('Group Delay plot');
end

OUTPUT:
Minimum phase system

Maximum phase system

CENTRAL ELECTRONICS ENGINEERING RESEARCH INSTITUTE, PILANI, RAJASTHAN, INDIA-333 031 Page 39

Advanced Signal Processing Lab Report

Linear phase system

CENTRAL ELECTRONICS ENGINEERING RESEARCH INSTITUTE, PILANI, RAJASTHAN, INDIA-333 031 Page 40

Advanced Signal Processing Lab Report


II.4 A causal IIR system is characterized by a constant coefficient difference equation given by
Y(n) = x(n-1) 1.2 x(n-2) + x(n-3) + 1.3 y(n-1) 1.07 y(n-2) + 0.222 y(n-3)
Find the location of poles zeros of this system. Using MATLAB plot magnitude, phase and group
delay.

CODE:
test_4.m

% % %Lab Assignment-4
% % %Author:TAPAS KUMAR DASH
% % %Trainee Scientist,PGRPE-2014
% II.4 A causal IIR system is characterized by a constant
%coefficient difference equation given by
%
% Y(n) = x(n-1) 1.2 x(n-2) + x(n-3) + 1.3 y(n-1) 1.07 y(n-2) + 0.222 y(n3)
%
Find the location of poles zeros of this system.
%Using MATLAB plot magnitude, phase and group delay.
clc
close all
clear all
num=[0 1 -1.2 1];
den=[1 -1.3 1.07 -0.222];
h=filt(num,den);
zeroes=zero(h);
poles=pole(h);
k=1;
figure,frequency_response(zeroes,poles,k);

frequency_response.m
function [ y ] = frequency_response(Z,p,k)
%FREQUENCY_RESPONSE Summary of this function goes here
%Frequncy Response of a filter given poles and zeros
w=0:pi/100:2*pi;
z=exp(1i*w);
np=poly(Z);
dp=poly(p);
numer=polyval(np,z);
denom=polyval(dp,z);
h=k*(numer./denom);
theta=atan2(imag(h),real(h));
%pole zero plot
subplot(2,2,1),zplane(Z,p),grid,title('Pole-Zero plot');

CENTRAL ELECTRONICS ENGINEERING RESEARCH INSTITUTE, PILANI, RAJASTHAN, INDIA-333 031 Page 41

Advanced Signal Processing Lab Report


%magnitude plot
subplot(2,2,2),plot(w,20*log10(abs(h))),grid,title('Magnitude plot(dB)');
%Phase plot
subplot(2,2,3),plot(w,theta),grid,title('Phase plot');
%Group delay plot
[gd,w1]=grpdelay(np,dp,1024,'whole');
subplot(2,2,4),plot(w1,gd),grid,title('Group Delay plot');
end

OUTPUT:

CENTRAL ELECTRONICS ENGINEERING RESEARCH INSTITUTE, PILANI, RAJASTHAN, INDIA-333 031 Page 42

Advanced Signal Processing Lab Report


II.5

The zero locations of FIR transfer functions of order 6 are sketched as shown in the figure.
a) Does any one of the FIR filters have a linear phase response? If so which one?

b) Does any one of the FIR filters have a minimum phase response? If so which one?

Comment:
system 1 is non-linear and non minimum phase
System 2 is linear and non minimum phase
System 3 is non-linear and non minimum phase
System 4 is non-linear and non minimum phase
CODE:
test_5.m
% % %Lab Assignment-4
% % %Author:TAPAS KUMAR DASH
% % %Trainee Scientist,PGRPE-2014
%check linear phase and minimum phase system

CENTRAL ELECTRONICS ENGINEERING RESEARCH INSTITUTE, PILANI, RAJASTHAN, INDIA-333 031 Page 43

Advanced Signal Processing Lab Report


%System 1
zero=[-2 -0.5 0.5+0.5j 0.5+0.5j 0.5-0.5j 0.5-0.5j];
pole=[0 0 0 0 0 0];
res1=verify_linear_phase(zero);
res2=verify_minimumphasesystem_pz(zero,pole);
num1=poly(zero);
den1=poly(pole);
if res1==1
str1='system 1 is linear';
else
str1='system 1 is non-linear';
end
if res2==1
str1=strcat(str1,' and minimum phase');
else
str1=strcat(str1,' and non minimum phase');
end
%System 2
zero=[-2 -0.5 0.5+0.5j 0.5-0.5j 1+1j 1-1j];
pole=[0 0 0 0 0 0];
res1=verify_linear_phase(zero);
res2=verify_minimumphasesystem_pz(zero,pole);
num2=poly(zero);
den2=poly(pole);
if res1==1
str2='System 2 is linear';
else
str2='System 2 is non-linear';
end
if res2==1
str2=strcat(str2,' and minimum phase');
else
str2=strcat(str2,' and non minimum phase');
end
%System 3
zero=[-0.5 -0.5 0.5+0.5j 0.5-0.5j 1+1j 1-1j];
pole=[0 0 0 0 0 0];
res1=verify_linear_phase(zero);
res2=verify_minimumphasesystem_pz(zero,pole);
num3=poly(zero);
den3=poly(pole);
if res1==1
str3='System 3 is linear';
else
str3='System 3 is non-linear';
end
if res2==1
str3=strcat(str3,' and minimum phase');
else
str3=strcat(str3,' and non minimum phase');
end
%System 4
zero=[-2 -2 1+1j 1+1j 1-1j 1-1j];

CENTRAL ELECTRONICS ENGINEERING RESEARCH INSTITUTE, PILANI, RAJASTHAN, INDIA-333 031 Page 44

Advanced Signal Processing Lab Report


pole=[0 0 0 0 0 0];
res1=verify_linear_phase(zero);
res2=verify_minimumphasesystem_pz(zero,pole);
num4=poly(zero);
den4=poly(pole);
if res1==1
str4='System 4 is linear';
else
str4='System 4 is non-linear';
end
if res2==1
str4=strcat(str4,' and minimum phase');
else
str4=strcat(str4,' and non minimum phase');
end
disp(str1);
disp(str2);
disp(str3);
disp(str4);
h1=filt(num1,den1);
subplot(2,2,1)
pzmap(h);
h2=filt(num2,den2);
subplot(2,2,2)
pzmap(h2);
h3=filt(num3,den3);
subplot(2,2,3)
pzmap(h3);
h4=filt(num4,den4);
subplot(2,2,4)
pzmap(h4);

verify_linear_phase.m
function [res]=verify_linear_phase(zero)
%For linear phase, the response should always be symmetric
%or antisymmetric in time domain
%And we can observe linearity only for FIR filters
h=poly(zero);
flag=0;
N=length(h);
for i=1:N
if uint8(h(i)*10000)==uint8(h(N+1-i)*10000)
flag=flag+1;
end
end
if flag==N
res=1;

CENTRAL ELECTRONICS ENGINEERING RESEARCH INSTITUTE, PILANI, RAJASTHAN, INDIA-333 031 Page 45

Advanced Signal Processing Lab Report


else
res=0;
end

verify_minimumphasesystem_pz.m
function [res] = verify_minimumphasesystem_pz(zero,pole)
pole_mag=abs(pole);
zero_mag=abs(zero);
if max(pole_mag)<1 && max(zero_mag)<1
res=1;
else
res=0;
end
end

OUTPUTS:

CENTRAL ELECTRONICS ENGINEERING RESEARCH INSTITUTE, PILANI, RAJASTHAN, INDIA-333 031 Page 46

Advanced Signal Processing Lab Report


II.6 a) A minimum-phase system has a system function Hmin(z) is such that
Hmin(z)Hap(z) = Hlin(z),
Where Hap(z) is an all-pass system function and Hlin(z) is a causal generalized linear phase system.
What does this information tell you about the poles and zeros of Hmin(z)?
b) A generalized linear- phase FIR system has an impulse response with real values and h[n] = 0
for n < 0 and for n 8 and h[n] = -h[7-n]. The system function of this system has zero at

z=

0.8ej/4 and another zero at z=-2. What is H(z)?

Solution:
a) The poles and zeros of Hmin (z) are inside the unit circle which are reciprocal
conjugates of poles and zeros of Hlin (z) which are magnitude of greater than 1.
b) The filter is TYPE-IV .An odd number of zeros at z=1 and either an even number or
no zeros at z=-1.
So
=

+ 1

II.7 A causal LTI discrete time system has system function


H(Z) = ((1-0.5z-1)(1+4z-2))/(1-0.64z-2).

a)

.8 4 1

+ 1

Find expressions for minimum phase system H1(z) and an all-pass system Hap(z), such that

H(z) = H1(z)Hap(z)
b)

Find expressions for a different minimum phase system H2(z) and a generalized linear phase

FIR system Hlin(z) such that


H(z) = H2(z)Hlin(z).

CODE:
test_7.m
% % %Lab Assignment-7
% % %Author:TAPAS KUMAR DASH
% % %Trainee Scientist,PGRPE-2014
%II.7
A causal LTI discrete time system has system function
%
H(Z) = ((1-0.5z-1)(1+4z-2))/(1-0.64z-2).
%find minimum phase,all pass and linear phase system

CENTRAL ELECTRONICS ENGINEERING RESEARCH INSTITUTE, PILANI, RAJASTHAN, INDIA-333 031 Page 47

Advanced Signal Processing Lab Report


zero=[0.5;2i;-2i];
pole=[0.64;-0.64];
k=1;
compensation_system_design( zero,pole,k );

compensation_system_design.m
function [ y ] = compensation_system_design( z,p,k )
%COMPENSATION_SYSTEM_DESIGN Summary of this function goes here
%Function to find Minimuam phase and All pass system for a given system
%H(z)=Hmin(z)*Hap(z)
%GIVEN SYSTEM Response
figure('Name','Given System'),frequency_response(z,p,k);
%Construction of MINIMUM PAHSE SYSTEM
z1=z;
for i=1:length(z)
if(abs(z(i))>1)
z1(i)=1/(conj(z(i)));
end
end
p1=p;
for j=1:length(p)
if(abs(p(j))>1)
p1(j)=1/conj(p(j));
end
end
figure('Name','Minimum Phase System'),frequency_response(z1,p1,k);
z3=p1;
p3=z1;
figure('Name','Inverse of Minimum Phase System(compensation
system)'),frequency_response(z3,p3,k);
%ALL PASS SYSTEM
q=1;
for k=1:length(z)
if(abs(z(k))>1)
z2(q,1)=z(k);
p2(q,1)=1/conj(z(k));
q=q+1;
end
end
r=q+1;
for l=1:length(p)
if(abs(p(l))>1)
p2(r,1)=p(l);
z2(r,l)=1/conj(p(l));
r=r+1;
end
end

CENTRAL ELECTRONICS ENGINEERING RESEARCH INSTITUTE, PILANI, RAJASTHAN, INDIA-333 031 Page 48

Advanced Signal Processing Lab Report


figure('Name','All Pass System(output
response)'),frequency_response(z2,p2,1);
end

OUTPUT:

CENTRAL ELECTRONICS ENGINEERING RESEARCH INSTITUTE, PILANI, RAJASTHAN, INDIA-333 031 Page 49

Advanced Signal Processing Lab Report

CENTRAL ELECTRONICS ENGINEERING RESEARCH INSTITUTE, PILANI, RAJASTHAN, INDIA-333 031 Page 50

Advanced Signal Processing Lab Report


II.8 Figure shows the pole-zero plots for three different causal LTI systems with real impulse responses.
Indicate which of the following properties apply to each of the systems pictured: stable, IIR, FIR,
minimum phase , all-pass generalized linear phase, positive group delay at all ?

Solution:
CODE:
test_8.m
%Lab Assignment-8
%Author:TAPAS KUMAR DASH
%Trainee Scientist,PGRPE-2014
% Figure shows the pole-zero plots for three different causal LTI systems
% with real impulse responses. Indicate which of the following properties
% apply to each of the systems pictured: stable, IIR, FIR, minimum phase ,
clc
clear all
close all

CENTRAL ELECTRONICS ENGINEERING RESEARCH INSTITUTE, PILANI, RAJASTHAN, INDIA-333 031 Page 51

Advanced Signal Processing Lab Report


%a)
pole1=[1+1j; 1-1j; -0.5];
zero1=0.5;
str1='';
res1=verify_stability(zero1,pole1);
res2=verify_iir_fir(zero1,pole1);
res3=verify_minimumphasesystem_pz(zero1,pole1);
res4=verify_allpass(zero1,pole1);
res5=verify_linear_phase(zero1);
if res1==1
str1=strcat(str1,'1st system is: stable');
else
str1=strcat(str1,'1st system is: unstable');
end
if res2==1
str1=strcat(str1,' fir');
if res5==1
str1=strcat(str1,' linear-phase');
else
str1=strcat(str1,' non-linear-phase');
end
else
str1=strcat(str1,' iir non-linear-phase');
end
if res3==1
str1=strcat(str1,' minimum-phase');
else
str1=strcat(str1,' non-minimum-phase');
end
if res4==1
str1=strcat(str1,' all-pass');
else
str1=strcat(str1,' non-all-pass');
end
disp(str1)
%
% %b)
pole2=[0];
zero2=[-1; -0.707+0.707j; +1j; +0.707+0.707j;
+0.707-0.707i;
0.707j];
num2=poly(zero2);
den2=poly(pole2);
str2='';
res1=verify_stability(zero2,pole2);
res2=verify_iir_fir(zero2,pole2);
res3=verify_minimumphasesystem_pz(zero2,pole2);
res4=verify_allpass(zero2,pole2);
res5=verify_linear_phase(zero2);
if res1==1
str2=strcat(str2,'2nd system is: stable');
else
str2=strcat(str2,'2nd system is: unstable');
end
if res2==1

-1j; -0.707-

CENTRAL ELECTRONICS ENGINEERING RESEARCH INSTITUTE, PILANI, RAJASTHAN, INDIA-333 031 Page 52

Advanced Signal Processing Lab Report


str2=strcat(str2,' fir');
if res5==1
str2=strcat(str2,' linear-phase');
else
str2=strcat(str2,' non-linear-phase');
end
else
str2=strcat(str2,' iir non-linear-phase');
end
if res3==1
str2=strcat(str2,' minimum-phase');
else
str2=strcat(str2,' non-minimum-phase');
end
if res4==1
str2=strcat(str2,' all-pass');
else
str2=strcat(str2,' non-all-pass');
end
disp(str2)
% %c)
pole3=[0.5+0.5j; 0.5-0.5j; -0.5];
zero3=[-2 ;1+1j ;1-1j];
str3='';
res1=verify_stability(zero3,pole3);
res2=verify_iir_fir(zero3,pole3);
res3=verify_minimumphasesystem_pz(zero3,pole3);
res4=verify_allpass(zero3,pole3);
res5=verify_linear_phase(zero3);
if res1==1
str3=strcat(str3,'3rd system is: stable');
else
str3=strcat(str3,'3rd system is: unstable');
end
if res2==1
str3=strcat(str3,' fir');
if res5==1
str3=strcat(str3,' linear-phase');
else
str3=strcat(str3,' non-linear-phase');
end
else
str3=strcat(str3,' iir non-linear-phase');
end
if res3==1
str3=strcat(str3,' minimum-phase');
else
str3=strcat(str3,' non-minimum-phase');
end
if res4==1
str3=strcat(str3,' all-pass');
else
str3=strcat(str3,' non-all-pass');
end
disp(str3);

CENTRAL ELECTRONICS ENGINEERING RESEARCH INSTITUTE, PILANI, RAJASTHAN, INDIA-333 031 Page 53

Advanced Signal Processing Lab Report


subplot(3,1,1)
zplane(zero1,pole1);
title(str1);
subplot(3,1,2)
% pzmap(num2,den2);
zplane(zero2,pole2);
title(str2);
subplot(3,1,3)
zplane(zero3,pole3);
title(str3);

verify_allpass.m
function [res] = verify_allpass(zero,pole)
%If there are no poles then FIR
nz=length(zero);
np=length(pole);
zflag=0;
pflag=0;
for i=1:nz
for j=1:np
if pole(j)==1/conj(zero(i))
zflag=zflag+1;
break;
end
end
end
for i=1:np
for j=1:nz
if zero(j)==1/conj(pole(i))
pflag=pflag+1;
end
end
end
if zflag==nz && pflag==np
res=1;
else
res=0;
end

verify_iir_fir.m
function [res] = verify_iir_fir(zero,pole)
%If there are no poles then FIR
if max(abs(pole))==0
res=1;
%FIR
else
%IIR
res=0;
end
end

CENTRAL ELECTRONICS ENGINEERING RESEARCH INSTITUTE, PILANI, RAJASTHAN, INDIA-333 031 Page 54

Advanced Signal Processing Lab Report


verify_linear_phase.m
function [res]=verify_linear_phase(zero)
%For linear phase, the response should always be symmetric
%or antisymmetric in time domain
%And we can observe linearity only for FIR filters
h=poly(zero);
flag=0;
N=length(h);
for i=1:N
if uint8(h(i)*10000)==uint8(h(N+1-i)*10000)
flag=flag+1;
end
end
if flag==N
res=1;
else
res=0;
end

verify_stability.m
function [res] =verify_stability(zero,pole)
%If all the poles are inside unit circle then system is stable
if max(abs(pole))<1
res=1; %Stable
else
res=0;
end
end

verify_minimumphasesystem_pz.m
function [res] = verify_minimumphasesystem_pz(zero,pole)
pole_mag=abs(pole);
zero_mag=abs(zero);
if max(pole_mag)<1 && max(zero_mag)<1
res=1;
else
res=0;
end
end

CENTRAL ELECTRONICS ENGINEERING RESEARCH INSTITUTE, PILANI, RAJASTHAN, INDIA-333 031 Page 55

Advanced Signal Processing Lab Report


PLOTS:

Comment:
1st system is: unstable iir non-linear-phase non-minimum-phase non-all-pass
2nd system is: stable fir linear-phase minimum-phase non-all-pass
3rd system is: stable iir non-linear-phase non-minimum-phase all-pass

CENTRAL ELECTRONICS ENGINEERING RESEARCH INSTITUTE, PILANI, RAJASTHAN, INDIA-333 031 Page 56

Advanced Signal Processing Lab Report


II.9 The z-tranforms of five sequences of length 7 are given as:
H1(z) = 0.0083653-0.001782726z-1 -0.075506z-2 -0.3413956532z-3 +0.13529123z-4 -1.50627293z-5 +
3.3207295z-6,
H2(z) = 3.3207295-1.50627293z-1 + 0.13529123 z-2 + 0.34139565 z-3 0.07550603 z-4 0.001782725 z-5
+ 0.0083652 z-6
H3(z) = 0.0269311 0.0840756z-1 +0.02580603 z-2 + 0.94049849 z-3 - 2.2508765z-4 + 2.53245711z5+
1.03147943 z-6
H4(z) = 10.03147943 + 2.5324571 z-1 + 2.2508765 z-2 +0.94044985 z-3 +0.02580602 z-4
0.0840756 z-5 +0.02693111z-6
H5(z) = 0.16667 0.05556z-1 -0.75z-2 + 3.5z-3 -0.75z-4 -0.05556z-5 +0.16667z-6
The magnitude of the DFT for each of the above sequences is the same which one of the above ztransforms has all its zeros outside the unit circle? Which one has all its zeros inside the unit circle?

CODE:
test_9.m
%Lab Assignment-9
%Author:TAPAS KUMAR DASH
%Trainee Scientist,PGRPE-2014
%
% The z-tranforms of five sequences of length 7 are given as:
%
H1(z) = 0.0083653-0.001782726z-1 -0.075506z-2 -0.3413956532z-3
+0.13529123z-4 -1.50627293z-5 + 3.3207295z-6,
%
H2(z) = 3.3207295-1.50627293z-1 + 0.13529123 z-2 + 0.34139565 z-3
0.07550603 z-4 0.001782725 z-5 + 0.0083652 z-6
%
H3(z) = 0.0269311 0.0840756z-1 +0.02580603 z-2 + 0.94049849 z-3 2.2508765z-4 + 2.53245711z5+ 1.03147943 z-6
%
H4(z) = 10.03147943 + 2.5324571 z-1 + 2.2508765 z-2 +0.94044985 z-3
+0.02580602 z-4
0.0840756 z-5 +0.02693111z-6
%
H5(z) = 0.16667 0.05556z-1 -0.75z-2 + 3.5z-3 -0.75z-4 -0.05556z-5
+0.16667z-6
%
%
The magnitude of the DFT for each of the above sequences is the same
%which one of the above z-transforms has all its zeros outside the unit
%circle? Which one has all its zeros inside the unit circle?
close all;
clear all;
clc
format long
b1=[0.0083653 0.001782726 0.075506 0.3413956532 0.13529123 1.50627293
3.3207295];
a1=1;
h1=filt(b1,a1);
figure(1),frequency_response(zero(h1),pole(h1),1);
b2=[3.3207295 -1.50627293 0.13529123 0.34139565 0.07550603 0.001782725
0.0083652];
a2=1;
h2=filt(b2,a2);

CENTRAL ELECTRONICS ENGINEERING RESEARCH INSTITUTE, PILANI, RAJASTHAN, INDIA-333 031 Page 57

Advanced Signal Processing Lab Report


figure(2),frequency_response(zero(h2),pole(h2),1);
b3=[0.0269311 0.0840756 0.02580603 0.94049849 -2.2508765 2.53245711
1.03147943];
a3=[1];
h3=filt(b3,a3);
figure(3),frequency_response(zero(h3),pole(h3),1);
b4=[10.03147943 2.5324571 2.2508765 0.94044985 0.02580602 0.0840756
0.02693111];
a4=[1];
h4=filt(b4,a4);
figure(4),frequency_response(zero(h4),pole(h4),1);
b5=[0.16667 0.05556 -0.75 3.5 -0.75 0.05556 0.16667];
a5=[1];
h5=filt(b5,a5);
figure(5),frequency_response(zero(h5),pole(h5),1);

frequency_response.m
function [ y ] = frequency_response(Z,p,k)
%FREQUENCY_RESPONSE Summary of this function goes here
%Frequncy Response of a filter given poles and zeros
w=0:pi/100:2*pi;
z=exp(1i*w);
np=poly(Z);
dp=poly(p);
numer=polyval(np,z);
denom=polyval(dp,z);
h=k*(numer./denom);
theta=atan2(imag(h),real(h));
%pole zero plot
subplot(2,2,1),zplane(Z,p),grid,title('Pole-Zero plot');
%magnitude plot
subplot(2,2,2),plot(w,20*log10(abs(h))),grid,title('Magnitude plot(dB)');
%Phase plot
subplot(2,2,3),plot(w,theta),grid,title('Phase plot');
%Group delay plot
[gd,w1]=grpdelay(np,dp,1024,'whole');
subplot(2,2,4),plot(w1,gd),grid,title('Group Delay plot');
end

CENTRAL ELECTRONICS ENGINEERING RESEARCH INSTITUTE, PILANI, RAJASTHAN, INDIA-333 031 Page 58

Advanced Signal Processing Lab Report


PLOTS:

CENTRAL ELECTRONICS ENGINEERING RESEARCH INSTITUTE, PILANI, RAJASTHAN, INDIA-333 031 Page 59

Advanced Signal Processing Lab Report

CENTRAL ELECTRONICS ENGINEERING RESEARCH INSTITUTE, PILANI, RAJASTHAN, INDIA-333 031 Page 60

Advanced Signal Processing Lab Report

CONCLUSION:
1. Among all systems H1(z) has all it's zeros outside the unit circle and H2(z)
and H4(z) have all zeros inside the unit circle.
2. Frequency response for all 5 system were plotted.

CENTRAL ELECTRONICS ENGINEERING RESEARCH INSTITUTE, PILANI, RAJASTHAN, INDIA-333 031 Page 61

Advanced Signal Processing Lab Report


II.10 The transfer function of a typical transmission channel is given by
H(z) = (z-0.3)(z2 2z +2)/(z-0.9)(z-0.5)
In order to correct for the magnitude distortion introduced by the channel on a signal passing
through it we wish to connect a stable digital filter characterized by a transfer function G(z) at the
receiving end. Determine G(z).

COMMENT:

The perfect compensation is possible only if Hd(z) is a minimum phase system.


G(z)=Hd(z)*Hc(z)
If Hd(z) isnt a minimum phase system then we can write
Hd(z)=Hdmin(z) Hap(z)

and
Compensating system

Hc(z) =1/Hdmin(z).

G(z)=Hap(z).

CODE:
test_10.m
%Lab Assignment-10
%Author:TAPAS KUMAR DASH
%Trainee Scientist,PGRPE-2014
%The transfer function of a typical transmission channel is given by
%
H(z) = (z-0.3)(z^2 2z +2)/(z-0.9)(z-0.5)
%In order to correct for the magnitude distortion introduced by

CENTRAL ELECTRONICS ENGINEERING RESEARCH INSTITUTE, PILANI, RAJASTHAN, INDIA-333 031 Page 62

Advanced Signal Processing Lab Report


%the channel on a signal passing through it we wish to connect a stable
%digital filter characterized by a transfer function G(z) at the receiving
%end. Determine G(z).

clc
clear all
close all

pole=[0.9 0.5];
zero=[0.3 1+i 1-i];
res=verify_minimumphasesystem_pz(zero,pole);
str='';
if res==1
str=strcat(str,'System is minimum-phase');
else
str=strcat(str,'System is non-minimum-phase');
end
disp(str);
compensation_system_design([0.3;1+i;1-i],[0.9;0.5],1);

frequency_response.m
function [ y ] = frequency_response(Z,p,k)
%FREQUENCY_RESPONSE Summary of this function goes here
%Frequncy Response of a filter given poles and zeros
w=0:pi/100:2*pi;
z=exp(1i*w);
np=poly(Z);
dp=poly(p);
numer=polyval(np,z);
denom=polyval(dp,z);
h=k*(numer./denom);
theta=atan2(imag(h),real(h));
%pole zero plot
subplot(2,2,1),zplane(Z,p),grid,title('Pole-Zero plot');
%magnitude plot
subplot(2,2,2),plot(w,20*log10(abs(h))),grid,title('Magnitude plot(dB)');
%Phase plot
subplot(2,2,3),plot(w,theta),grid,title('Phase plot');
%Group delay plot
[gd,w1]=grpdelay(np,dp,1024,'whole');
subplot(2,2,4),plot(w1,gd),grid,title('Group Delay plot');
end

verify_minimumphasesystem_pz.m
function [res] = verify_minimumphasesystem_pz(zero,pole)

CENTRAL ELECTRONICS ENGINEERING RESEARCH INSTITUTE, PILANI, RAJASTHAN, INDIA-333 031 Page 63

Advanced Signal Processing Lab Report


pole_mag=abs(pole);
zero_mag=abs(zero);
if max(pole_mag)<1 && max(zero_mag)<1
res=1;
else
res=0;
end
end

compensation_system_design.m
function [ y ] = compensation_system_design( z,p,k )
%COMPENSATION_SYSTEM_DESIGN Summary of this function goes here
%Function to find Minimuam phase and All pass system for a given system
%H(z)=Hmin(z)*Hap(z)
%GIVEN SYSTEM Response
figure('Name','Given System'),frequency_response(z,p,k);
%Construction of MINIMUM PAHSE SYSTEM
z1=z;
for i=1:length(z)
if(abs(z(i))>1)
z1(i)=1/(conj(z(i)));
end
end
p1=p;
for j=1:length(p)
if(abs(p(j))>1)
p1(j)=1/conj(p(j));
end
end
figure('Name','Minimum Phase System'),frequency_response(z1,p1,k);
z3=p1;
p3=z1;
figure('Name','Inverse of Minimum Phase System(compensation
system)'),frequency_response(z3,p3,k);
%ALL PASS SYSTEM
q=1;
for k=1:length(z)
if(abs(z(k))>1)
z2(q,1)=z(k);
p2(q,1)=1/conj(z(k));
q=q+1;
end
end
r=q+1;
for l=1:length(p)
if(abs(p(l))>1)
p2(r,1)=p(l);
z2(r,l)=1/conj(p(l));

CENTRAL ELECTRONICS ENGINEERING RESEARCH INSTITUTE, PILANI, RAJASTHAN, INDIA-333 031 Page 64

Advanced Signal Processing Lab Report


r=r+1;
end
end
figure('Name','All Pass System(outputresponse)'),frequency_response(z2,p2,1);
end

PLOTS:

CENTRAL ELECTRONICS ENGINEERING RESEARCH INSTITUTE, PILANI, RAJASTHAN, INDIA-333 031 Page 65

Advanced Signal Processing Lab Report

CENTRAL ELECTRONICS ENGINEERING RESEARCH INSTITUTE, PILANI, RAJASTHAN, INDIA-333 031 Page 66

Advanced Signal Processing Lab Report


CONCLUSION:
1.

Given System is a non-minimum phase system as all pole and zero are not
inside unit circle

2.

Minimum Phase system was found for the given system where all pole and
zero lies inside unit circle.

3.

To design compensation system its inverse is taken.

4.

Frequency response of all the system were plotted.

5.

Output of the entire system is all pass system whose frequency response is also
plotted.

CENTRAL ELECTRONICS ENGINEERING RESEARCH INSTITUTE, PILANI, RAJASTHAN, INDIA-333 031 Page 67

Advanced Signal Processing Lab Report


II.11 Is the transfer function
H(z) = (z+3)(z-2)/(z-0.25)(z+0.5)
Minimum phase? If it is not minimum phase, then construct a minimum phase transfer function
G(z) such that |G(ej)| = |H(ej)|. Determine their corresponding unit sample responses, g[n] and
h[n] , for n= 0,1,2,3,4. For what values of m is n=0m |g[n]|2 bigger than n=0m |h[n]|2 ?

CODE:
test_11.m
%Lab Assignment-11
%Author:TAPAS KUMAR DASH
%Trainee Scientist,PGRPE-2014
%Check Minimum Phase,Construct minimum phase system if given system is not
%minimum phase,find unit sample responseof g[n] and h[n],find value of m
%for which sum 0f squares of g[n] > sum of squares of h[n]
%H(z) = (z+3)(z-2)/(z-0.25)(z+0.5)
clc
clear all
close all
pole=[0.25 -0.5];
zero=[-3 2];
res=verify_minimumphasesystem_pz(zero,pole);
str='';
if res==1
str=strcat(str,'System is minimum-phase');
else
str=strcat(str,'System is non-minimum-phase');
end
disp(str);
construct_minimumphase_system([-3;2],[0.25;-0.5],1);
[b a]=zp2tf([-3;2],[0.25;-0.5],1);
[h,t]=impz(b,a,5);
figure,stem(t,h,'.','b'),grid,title('impulse response of h[n]');

frequency_response.m
CENTRAL ELECTRONICS ENGINEERING RESEARCH INSTITUTE, PILANI, RAJASTHAN, INDIA-333 031 Page 68

Advanced Signal Processing Lab Report


function [ y ] = frequency_response(Z,p,k)
%FREQUENCY_RESPONSE Summary of this function goes here
%Frequncy Response of a filter given poles and zeros
w=0:pi/100:2*pi;
z=exp(1i*w);
np=poly(Z);
dp=poly(p);
numer=polyval(np,z);
denom=polyval(dp,z);
h=k*(numer./denom);
theta=atan2(imag(h),real(h));
%pole zero plot
subplot(2,2,1),zplane(Z,p),grid,title('Pole-Zero plot');
%magnitude plot
subplot(2,2,2),plot(w,20*log10(abs(h))),grid,title('Magnitude plot(dB)');
%Phase plot
subplot(2,2,3),plot(w,theta),grid,title('Phase plot');
%Group delay plot
[gd,w1]=grpdelay(np,dp,1024,'whole');
subplot(2,2,4),plot(w1,gd),grid,title('Group Delay plot');
end

verify_minimumphasesystem_pz.m
function [res] = verify_minimumphasesystem_pz(zero,pole)
pole_mag=abs(pole);
zero_mag=abs(zero);
if max(pole_mag)<1 && max(zero_mag)<1
res=1;
else
res=0;
end
end

construct_minimumphase_system.m
function [ y ] = construct_minimumphase_system(z,p,k )
%Function to find Minimuam phase and All pass system for a given system
%H(z)=Hmin(z)*Hap(z)
%GIVEN SYSTEM Response
figure('Name','Given System'),frequency_response(z,p,k);
%Impulse response of given system
[b a]=zp2tf(z,p,k);
[h,t]=impz(b,a,25);
%Construction of MINIMUM PAHSE SYSTEM
z1=z;
for i=1:length(z)
if(abs(z(i))>1)
z1(i)=1/(conj(z(i)));
end

CENTRAL ELECTRONICS ENGINEERING RESEARCH INSTITUTE, PILANI, RAJASTHAN, INDIA-333 031 Page 69

Advanced Signal Processing Lab Report


end
p1=p;
for j=1:length(p)
if(abs(p(j))>1)
p1(j)=1/conj(p(j));
end
end
%Impulse response of minimum phase system
[b a]=zp2tf(z1,p1,k);
[g,t]=impz(b,a,25);
n=0;
f=0;
m=0;
g=g
h=h
%Code to find M
for i=1:length(g)
sqg=(g(i)*g(i))+n;
n=sqg;
sqh=0;
f=0;
for j=1:i
sqh=(h(j)*h(j))+f;
f=sqh;

end
if n>f
m=1;
m=i;
end
end
sum_of_squre_g=sqg
sum_of_squre_h=sqh
m
str1='';
if m==0
str=strcat(str1,'there is no such m exist where squre sum g is greater
than square sum of h');
end
disp(str);
[g,t]=impz(b,a,5);
figure,stem(t,g,'.','b'),grid,title('impulse response of g[n]');
figure('Name','Minimum Phase System'),frequency_response(z1,p1,k);

%ALL PASS SYSTEM


q=1;
for k=1:length(z)
if(abs(z(k))>1)

CENTRAL ELECTRONICS ENGINEERING RESEARCH INSTITUTE, PILANI, RAJASTHAN, INDIA-333 031 Page 70

Advanced Signal Processing Lab Report


z2(q,1)=z(k);
p2(q,1)=1/conj(z(k));
q=q+1;
end
end
r=q+1;
for l=1:length(p)
if(abs(p(l))>1)
p2(r,1)=p(l);
z2(r,l)=1/conj(p(l));
r=r+1;
end
end
figure('Name','All Pass System'),frequency_response(z2,p2,1);
end

RESULT:
System is non-minimum-phase
sample_values_g =Columns 1 through 11
1.0000 -0.4167 0.0625 -0.0677 0.0247 -0.0146 0.0068 -0.0035 0.0017 -0.0009 0.0004
Columns 12 through 22
-0.0002

0.0001 -0.0001 0.0000 -0.0000 0.0000 -0.0000 0.0000 -0.0000 0.0000 -0.0000

Columns 23 through 25
0.0000 -0.0000 0.0000
sample_values_h =
Columns 1 through 11
1.0000 0.7500 -6.0625 1.6094 -1.1602

0.4912 -0.2678 0.1284 -0.0656 0.0324 -0.0163

Columns 12 through 22
0.0081 -0.0041 0.0020 -0.0010 0.0005 -0.0003 0.0001 -0.0001 0.0000 -0.0000 0.0000
Columns 23 through 25
-0.0000

0.0000 -0.0000

sum_of_squre_g =1.1830
sum_of_squre_h = 42.5877
m=0
There is no such m exist where squre sum g is greater than square sum of h

CENTRAL ELECTRONICS ENGINEERING RESEARCH INSTITUTE, PILANI, RAJASTHAN, INDIA-333 031 Page 71

Advanced Signal Processing Lab Report


PLOTS:

CENTRAL ELECTRONICS ENGINEERING RESEARCH INSTITUTE, PILANI, RAJASTHAN, INDIA-333 031 Page 72

Advanced Signal Processing Lab Report

CENTRAL ELECTRONICS ENGINEERING RESEARCH INSTITUTE, PILANI, RAJASTHAN, INDIA-333 031 Page 73

Advanced Signal Processing Lab Report

CONCLUSION:
1.

System is a non-minimum phase system as all pole and zero are not inside unit
circle

2.

Minimum Phase system was found for the given system where all pole and
zero lies inside unit circle.

3.

Frequency response of all the system were plotted.

4.

Impulse response of g[n] and h[n] evaluated and plotted. Sum of their squares
were also calculated for comparison.

----------------------------------------------------------------END-------------------------------------------------------------

CENTRAL ELECTRONICS ENGINEERING RESEARCH INSTITUTE, PILANI, RAJASTHAN, INDIA-333 031 Page 74

S-ar putea să vă placă și