- Aug 15, 2006
- 375
- 1
- 81
I'm taken a Fourier transform of some equations and solving them using Matlab's ode45 routine. Next I want to inverse fft them back to spatial coordinates and I have a few questions about how Matlab does this.
To give a concrete example of my problem I start with the initial conditions:
I have a gaussian given by,
u(x,0) = exp( -x^2 ) [1]
The Fourier transform of this is simply another Gaussian,
u(k,0) = sqrt(pi) * exp( -(pi*k)^2 ) [2]
Now, with this in mind, I solve my equations and I decide to ifft the 1st time step. My expectations were that I should get [1]. Instead, I get a Gaussian that seems to be phaseshifted by pi? I'm not too sure on this, but instead of being centered at zero the peak of the Gaussian is split into 2 and located at the boundary (I have to take abs() of the resulting vector).
I've looked into this a bit and it has something to do with the fftshift function, but most of applications involved taking some combination of fftshift and fft of the data first. In my case, I've Fourier transformed everything analytically first and now am using Matlab to solve the resulting ODEs.
To give a concrete example of my problem I start with the initial conditions:
I have a gaussian given by,
u(x,0) = exp( -x^2 ) [1]
The Fourier transform of this is simply another Gaussian,
u(k,0) = sqrt(pi) * exp( -(pi*k)^2 ) [2]
Now, with this in mind, I solve my equations and I decide to ifft the 1st time step. My expectations were that I should get [1]. Instead, I get a Gaussian that seems to be phaseshifted by pi? I'm not too sure on this, but instead of being centered at zero the peak of the Gaussian is split into 2 and located at the boundary (I have to take abs() of the resulting vector).
I've looked into this a bit and it has something to do with the fftshift function, but most of applications involved taking some combination of fftshift and fft of the data first. In my case, I've Fourier transformed everything analytically first and now am using Matlab to solve the resulting ODEs.