Hilbert transfrorm via FFT procedure

function xH=hilbfft(x);
% A Hilbert transform (based on FFT) with filtering procedure
% for short and long data lengthx=x(:);Hilbert transfrorm via FFT procedure graph
xH=imag(hilbert(x));return

% Compare the original data and the Hilbert transformed data on a line plot:
close all
x=sin(0.06*(1:400))’;
xH=hilbfft(x);
figure(1)
plot(x,’-.’), grid on, hold on
plot(xH,’k-‘)
legend(‘Original’,’Hilbert transformed’)