Trying to compute Hilbert transform numerically

Click For Summary
SUMMARY

The discussion focuses on implementing the Hilbert transform numerically using Fourier transforms in MATLAB. The user has developed functions for the Fourier transform (ft), inverse Fourier transform (ift), and the Hilbert transform (hilbert), but is experiencing excessive oscillations in the output. The key formula utilized is the relationship between the Hilbert transform and the Fourier transform, specifically \(\widehat{\mathscr{H}(f)}(k)=-i\sgn(k)\hat{f}(k)\). The user seeks suggestions to mitigate the oscillations in the computed results.

PREREQUISITES
  • Understanding of Fourier transforms and their properties
  • Familiarity with MATLAB programming and numerical integration techniques
  • Knowledge of the Hilbert transform and its mathematical formulation
  • Experience with signal processing concepts, particularly in the context of oscillatory behavior
NEXT STEPS
  • Investigate the effects of windowing functions on Fourier transforms in MATLAB
  • Learn about the use of zero-padding in Fourier transforms to reduce oscillations
  • Explore advanced numerical techniques for improving the stability of the Hilbert transform
  • Examine the impact of sampling rates and discretization on the accuracy of numerical transforms
USEFUL FOR

Researchers, signal processing engineers, and MATLAB users who are implementing numerical methods for the Hilbert transform and seeking to improve the accuracy and stability of their results.

hunt_mat
Homework Helper
Messages
1,816
Reaction score
33
I know the result:
\widehat{\mathscr{H}(f)}(k)=-i\sgn (k)\hat{f}(k)

I want to use this to compute the Hilbert transform. I have written code for Fourier transform,inverse Fourier transform and that the Hilbert transform. My code is the following:
Code:
function y=ft(x,f,k)
n=length(k); %See now long the wave vector is
y=zeros(1,n); %Output is the same length
for i=1:n
    v_1=exp(-sqrt(-1)*k(i)*x); %Compute exp(-ikx)
    v_2=f.*v_1; %Compute integrand of Fourier transform
    y(i)=-trapz(v_2,x); %Compute transform
end

Code:
function y=ift(k,f_hat,x) %Inverse Fourier transform
n=length(x); %Compute the length of the x
y=zeros(1,n); %Solution has same length
a=1/(2*pi); %scaling factor
for i=1:n
v_1=exp(sqrt(-1)*k*x(i)); %Compute exp(ikx)
v_2=f_hat.*v_1; %Compute integrand of inverse Fourier transform
y(i)=-a*trapz(v_2,k); %Compute transform
end

Code:
function y=hilbert(x,f_x,z)

%This takes numerical input (x,f(x)) and evaluates the Hilbert transform at
%x=z;
k=-4:0.001:4; %Choose the range of the wave number
f_x_hat=ft(x,f_x,k); %Compute Fourier transform
dum=-sqrt(-1)*sign(k).*f_x_hat; %Multiply by -isgn(k)
y=ift(k,dum,z); %Take inverse Fourier transform.

My solution has LOTS of oscillations to it and I have no idea what is going on.

Any suggestions?
 

Attachments

Similar threads

  • · Replies 2 ·
Replies
2
Views
1K
  • · Replies 4 ·
Replies
4
Views
3K
  • · Replies 5 ·
Replies
5
Views
2K
  • · Replies 7 ·
Replies
7
Views
5K
  • · Replies 1 ·
Replies
1
Views
6K
  • · Replies 4 ·
Replies
4
Views
3K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 9 ·
Replies
9
Views
3K
  • · Replies 10 ·
Replies
10
Views
3K
  • · Replies 7 ·
Replies
7
Views
3K