fft-based differentiation on a non-periodic time span
4 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hi everybody
I'm puzzled with a basic property of the Fourier transform. We all know that if the fourier transform of f(t) is F(w), then the fourier transform of df/dt is simply jwF(w). Well, to show this numerically using fft you need your f(t) to be periodic on your time span. Suppose that you define f(x) = sin(x) for -pi<x<pi. I want to show that fft(cos(x)) = jw*fft(sin(x)). Consider the following code:
clc
clear
close all
N = pow2(6);
a = pi;
dx = 2*a/N;
x = -a+dx*(0:N-1);
m = 2*pi/(2*a)*[0:N/2-1, 0, -N/2+1:-1];
%%
f = sin(x);
fx = cos(x); % df/dx
Ff = fft(f);
Ffx = 1i*m.*Ff;
iFfx = real(ifft(Ffx(:),'symmetric'));
plot(x,iFfx,'b')
hold on
plot(x,fx,'ro')
which is perfect. But the problem arises when the function is not periodic over the specified domain. For example, if I choose a = 1 in the example above, I wouldn't be satisfied with the results anymore. Are there any tricks so that I can solve this problem?
Any suggestion is appreciated.
1 commentaire
zhoumu wu
le 23 Oct 2020
sunaina2018-Calculating Numerical Derivatives using Fourier Transform some pitfalls and how to avoid them
Réponses (0)
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!