First and second derivative of the function using fft?

Hi
Could anybody help me with derivative of function with fft, ifft, fftshift
Thanks!

 채택된 답변

David Young
David Young 2011년 12월 7일

0 개 추천

See my answer to this question.

댓글 수: 5

Thank you for your answer, but the idea is to compute approximation to first and second derivative of function (any) with *fft*...
The fft is always applied to numerical data, never to a function proper, so if you are asking about finding a derivative of a function using the fft, you must mean numerically estimating the derivative from data generated by calling that function.
The answer I referred you to does exactly that. The example code is for 2-D data, but the simplification to 1-D is trivial (and in fact you can use the exact same code, just on a vector). Getting the second derivative is simply a matter of multiplying again.
The key thing you need to know is how to write the derivative operator in the frequency domain. The answer I referred you has it, as ftdiff.
I see, second derivative you mention multiply again?!
i.e.
g = ifft(bsxfun(@times, fft(f), ftdiff))
gg = ifft(bsxfun(@times, fft(g), ftdiff))
Is that so?
Yes, you can do that. But you don't need the bsxfun if you're working in 1-D - you just multiply. In addition, you can do both multiplications before transforming back. So something like this:
F = fft(f);
FD = F .* ftdiff;
FDD = FD .* ftdiff;
fd = ifft(FD);
fdd = ifft(FDD);
where uppercase variables are in the frequency domain, and d or D means differentiated.
Thank you very much!

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Dr. Seis
Dr. Seis 2011년 12월 7일

0 개 추천

I have another example, here
In that case I am converting acceleration data to displacement, which is (double) integration in the time domain and division in the frequency domain. In the frequency domain, this is essentially done by dividing the complex acceleration amplitude at frequency 'f' by (sqrt(-1)*2*pi*f)^2.
To go from displacement to velocity, you would multiply the displacement amplitude at frequency 'f' by sqrt(-1)*2*pi*f
To go from displacement to acceleration you would multiply the displacement amplitude at frequency 'f' by (sqrt(-1)*2*pi*f)^2
This is what David was referring to when he says the second derivative is "simply a matter of multiplying again."

댓글 수: 1

I see, but I am doing numerical approximation, and exact, as I understood, my numerical approx is by fft, so in a sense multiplying again, doesn't mean multiply as I wrote???

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Programming에 대해 자세히 알아보기

질문:

2011년 12월 7일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by