Numerical implementation of Hilbert transform
古いコメントを表示
I have been trying to implement the Hilbert transform numerically but I have been having some trouble. The way I decided to do it is the use of Fourier transforms. The fourier transform of the Hilbert transform of f(x) is -i*sgn(k)*F(k), where F(k) is the Fourier transform of f(x).
I have written my own Fourier and inverse Fourier routines but I don't get nice results. Can anyone suggest anything? The picture (pdf) I have included shows my computational result and the value which it should be.
11 件のコメント
Have you tried the Signal Processing Toolbox function hilbert.m?
MuPAD also has the symbolic hilbert transform function.
Or perhaps you want to use this one:
This is MATLAB, not C C# C++ or else, you don't have to write your functions when there are already working and robust FFT and hilbert functions available.
Star Strider
2016 年 7 月 31 日
It would definitely help if you describe what you are doing in your functions, what the arguments are, and whether they are scalars or vectors. Without that, it’s impossible for me to understand them. The easiest way to comment them is to put several tabs to the right of each line and then describe what the line is doing. For example:
function y=ft(x,f,k)
n=length(k); % Frequency Vector ‘k’
y=zeros(1,n); % Output Vector ‘y’
for i=1:n
v_1=exp(-sqrt(-1)*k(i)*x); % Calculate Complex Frequency Vector ‘v1’
v_2=f.*v_1; % Multiply By Time-Domain Signal ‘f’
y(i)=-real(trapz(v_2,x)); % Integrate To Get Fourier Component At ...
end
I don’t know if any of these comments are actually correct because I don’t know what your function is doing or what the variables are. That’s the problem.
Mat Hunt
2016 年 7 月 31 日
Star Strider
2016 年 7 月 31 日
I understand about Fourier transforms, particularly for signal processing. It is not obvious what you are using them for, and what your variables are.
You can also substitute 1i for ‘sqrt(-1)’ eliminating the need for the evaluation and making for more efficient code.
You obviously know infinitely more about MATLAB coding of the Fourier and related integral transforms than we do, so I will leave you to it.
Mat Hunt
2016 年 7 月 31 日
Mat Hunt
2016 年 7 月 31 日
Walter Roberson
2016 年 7 月 31 日
"For a Fourier transform, you require f(x),x and a value k (called the wavenumber)"
Have you told Jean-Baptiste that?
Mat Hunt
2016 年 8 月 1 日
Walter Roberson
2016 年 8 月 1 日
Mat Hunt comments to me
I assume that you're unaware how much the Fourier transform is used in the area of surface wave modelling where the k variable is called different things.
Walter Roberson
2016 年 8 月 1 日
Mat, you are free to call anything you want a "Fourier transform", and to refuse to acknowledge anything other people call a "Fourier transform" as being what you would call a Fourier transform. But if you do so, then we have no common ground and you are going to need to solve the problem yourself.
The transform invented by Jean-Baptiste Joseph Fourier does not require a "k". There are alternative formulations that involve "k" and those formulations make it easier to approach various computations, but they are not the only possibilities.
fft() and ifft() do not implement the Fourier Transform: they implement the Fast Fourier Transform, and the Inverse Fast Fourier Transform, which are implementations of Discrete Fourier Transforms. The Symbolic Toolbox implements the (continuous) Fourier Transform http://www.mathworks.com/help/symbolic/fourier.html, and does so without explicit reference to the variables you indicate as being required. When I look at your code, I am pretty much certain that you are not interested in the continuous Fourier Transform and are instead interested in a Discrete Fourier Transform. However, I have only been reading code for 40 years so I could be mistaken.
Mat Hunt
2016 年 8 月 2 日
回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Transforms についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!