You are on page 1of 2

MATLAB CODE FOR DISCRETE HILBERT TRANSFORM

d1=[1 -1.25*i];d2=[1 1.25*i];d3=[1 -0.3333]; d4=[1 -0.5]; d5=[1


2.2222]; d6=[1 0.25];D1=conv(d1,d2);D2=conv(d3,d4);D3=conv(d5,d6);
D=conv((conv(D1,D2)),D3); %This represents the transfer function
D4=[D(7) D(6) D(5) D(4) D(3) D(2) D(1) zeros(1,7)];
%The sequence of length N=7 is made causal byappending 7
zeroes to it
D5=fft(D4); %DFT of causal sequence i.e. H(k)
D6=abs(D5);
D7=log10(D6);D8=ifft(D7);
D9=D8.*[0 1 1 1 1 1 1 0 -1 -1 -1 -1 -1 -1];
%Multiplication by Signum Function
H=fft(D9);
H1=imag(H); %Phase spectrum of minimum phase filter
R=D6.*cos(H1);I=D6.*sin(H1); %R=New real part of H(k);
I=New imaginary part of H(k)N=R+(i.*I);
%N=New DFTN2=ifft(N)N2 =Columns 1 through 93.9280 1.8425 1.1941 -0.4073 -0.3604 0.1638 -0.0308 0.0036 0.0744Columns 10 through 14-0.0039 0.1929 0.0056 0.3344 -0.7948>>
f=0:100:10000;
num=[D(7) D(6) D(5) D(4) D(3) D(2) D(1)]; den=[1];
>> num2=[N2(1) N2(2) N2(3) N2(4) N2(5) N2(6) N2(7)];
%IDFT Truncated to initial length of
sequence>> freqz(num,den,f,20000) %Magnitude response obtaine
d by sampling at fs=20kHz>> hold on;>> freqz(num2,den,f,20000)

You might also like