 #1
hunt_mat
Homework Helper
 1,741
 25
Main Question or Discussion Point
I know the result:
[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:
My solution has LOTS of oscillations to it and I have no idea what is going on.
Any suggestions?
[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:
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.
Any suggestions?
Attachments

45.1 KB Views: 135