FIR Digital Filter Design
Hilbert Transform Design Example
Comparison to use of the hilbert functionSearch Spectral Audio Signal Processing
Would you like to be notified by email when Julius Orion Smith III publishes a new entry into his blog?
Suppose we happened upon the hilbert function in Matlab:
help hilbert HILBERT Hilbert transform. HILBERT(X) is the Hilbert transform of the real part of vector X. The real part of the result is the original real data; the imaginary part is the actual Hilbert transform. See also FFT and IFFT. If X is a signal matrix, HILBERT(X) transforms the columns of X independently.
We might think the easiest way to design our desired filter would be
to call hilbert with an impulse signal
. Let's try this and see what happens:
Nh = M-2; % This looks best delta = [1,zeros(1,Nh)]; % zero-phase impulse % hilbert() simply zeros the negative-frequency bins in the FFT: hh = hilbert(delta); Hh = fft(hh); % Frequency response Lh = length(Hh); Hhp = [Hh(Lh/2+2:Lh), Hh(1:Lh/2+1)]; % Plot (-) freqs on the left Hhpn = abs(Hhp); Hhpn = Hhpn/max(Hhpn); fh = [0:Lh-1]/Lh - 0.5; plot(fh,20*log10(Hhpn)); grid; s = sprintf(... 'Frequency Response of Length %d hilbert() using Matlab',Lh); title(s); xlabel('Normalized Frequency (cycles/sample)'); ylabel('Gain (dB)') if saveplots, saveplot('MatlabHilbertFR.eps'); end; if dopause, disp('Pausing... RETURN to continue'); pause; end;
This looks very good. However, let's zero-pad the returned impulse response to see what's really going on in the frequency response . . .
hhzp = [hh(Lh/2+1:Lh), zeros(1,N-Lh), hh(1:Lh/2)];
Hhzp = fft(hhzp); % Frequency response
Hhp = [Hhzp(N/2+2:N), Hhzp(1:N/2+1)]; % plot (-) freqs on the left
Hhpn = abs(Hhp); Hhpn = Hhpn/max(Hhpn);
f = [1:N]/N - 0.5;
plot(f,20*log10(Hhpn)); grid;
s=sprintf(...
['Interpolated Frequency Response of Length %d ',...
'hilbert() using Matlab'],Lh);
title(s);
xlabel('Normalized Frequency (cycles/sample)');
ylabel('Gain (dB)')
if saveplots, saveplot('MatlabHilbertInterpFR.eps'); end;
if dopause, disp('Pausing... RETURN to continue'); pause; end;
% Zoom in on low-frequency transition band
kshow = N/20;
kzero = N/2+1; % index of frequency 0
krange = kzero-kshow : kzero+kshow;
frange = (krange - kzero)/N;
plot(frange,20*log10(Hhpn(krange))); grid;
hold on; plot((k1-1)/N,1,'+'); hold off;
s = sprintf(...
['Low-Frequency Transition Band, ',...
'f1/fs=%f (marked by "+")'],f1/fs);
title(s);
xlabel('Normalized Frequency (cycles/sample)');
ylabel('Gain (dB)')
if saveplots, saveplot('MatlabHilbertInterpZoomFR.eps'); end;
if dopause, disp 'Pausing... RETURN to continue'; pause; end;
We found the following problems using hilbert:
.
