I know the result:(adsbygoogle = window.adsbygoogle || []).push({});

[tex]\widehat{\mathscr{H}(f)}(k)=-i\sgn (k)\hat{f}(k)[/tex]

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 (Text):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

endCode (Text):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

endMy solution has LOTS of oscillations to it and I have no idea what is going on.Code (Text):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.

Any suggestions?

**Physics Forums | Science Articles, Homework Help, Discussion**

Join Physics Forums Today!

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

# MATLAB Trying to compute Hilbert transform numerically

Have something to add?

Draft saved
Draft deleted

**Physics Forums | Science Articles, Homework Help, Discussion**