MATLAB的实现Hilbert变换程序如下:
N=20; n=0:N-1;
xn=cos(0.2*pi*n);
hxn=hilbert(xn);
%part 1
%compare FFT[x(n)] and FFT[Hilbert[x(n)]]
Xk=fft(xn);
hXk=fft(hxn);
aXk=abs(Xk);
ahXk=abs(hXk);
pXk=phase(Xk);
phXk=phase(hXk);
k=0:N-1;
subplot(2,2,1),stem(k,aXk)
xlabel('k');
title('amplitude of FFT[x(n)]');
subplot(2,2,2),stem(k,pXk)
xlabel('k');
title('phase of FFT[x(n)]');
subplot(2,2,3),stem(k,ahXk)
xlabel('k');
title('amplitude of Hilbert[x(n)]');
subplot(2,2,4),stem(k,phXk)
xlabel('k');
title('phase of FFT[Hilbertx(n)]');
%part 2
%method:if sum(xn.*hxn) is closely 0
add=sum(xn.*hxn)
%part 3:compare expansion function yhilbert.m and hilbert.m
y=hilbert(xn);
hxn
sn=sin(0.2*pi*n)
yn=imag(y)
|
|