fft2 function in matlab
显示 更早的评论
Does anyone have idea or good tutorials for manually programming a fft2 function (discrete fast fourier transform)?
The function already exists in MATLAB, I just want to be able to understand how it works
采纳的回答
更多回答(2 个)
Dr. Seis
2011-12-30
The 2D case is associated with double integration... so the 1D case is single integration. The above answer will simplify down to the 1D case if you only have 1 sample location (e.g., only one "x" or only one "t"). So, for example, if you only had one spatial location (i.e., x = 0), then you would not need any of the variables associated with "Nx" or "dx". You would also not need the FOR loops associated with "Nx" either. Your FOR loop above would simply to:
data_time = randn(Nt,1);
data_frequency = zeros(size(data_time));
% Compute 1D Discrete Fourier Transform
for j1 = 1 : Nt
for j2 = 1 : Nt
data_frequency(j1) = data_frequency(j1) + ...
data_time(j2)*exp(-1i*(2*pi)*(f(j1)*t(j2)))*dt;
end
end
5 个评论
Dr. Seis
2011-12-30
Incidentally, do you understand why I am multiplying things by "dt" (in the 1D example) and "dx*dt" (in the 2D example)?
ddd
2011-12-30
Dr. Seis
2011-12-30
1. "dx*dt" or "dt" is included in the calculation for determining the discrete integral (i.e., summation). Above, I am computing the area (length x width) under each data point and summing all those areas together. If you do not include these values, it is implicitly assumed that width between samples (i.e., dx or dt) is 1 unit. However, it is likely that your data were not sampled at 1 unit per sample (e.g., most quality seismic data is rarely collected at 1 second per sample). If you simply want to look at the shape of your data in the frequency domain, then it is not necessary to include this as you will be multiplying your data by the same constant. However, if you plan to do any sort of calculations from the amplitude information in the frequency domain, then it is important that you include this information because your amplitudes will be off by 1/(dx*dt) or 1/dt (in the examples above).
2. Yes, the plots are simply showing that you get the same result (to double precision) in either case.
Umar Farooq Ghumman
2018-4-4
Can you elaborate how the space changes to frequency domain? Initially you had distances on x-axis and time on y-axis. What will be the result of FFt2 on the space of this data? it will most definitely not be in time and distance space.
Kristian Torres
2019-12-2
编辑:Kristian Torres
2019-12-2
Hi. Does this mean that we also need to multiply df*dk if we are applying the Inverse fourier transform (e.g. ifft2(ifftshift(dummy))*df*dk )??
EDIT: I realized that the way I get the right amplitudes back through the inverse fft is with ifft2(ifftshift(dummy))/(dx*dt).
Thank you!
Bill Wood
2021-9-29
0 个投票
It seems that for any square matrix A, fft2(A) = fft(fft(A).').' although I do get small differences when I compute this both ways. Differences in implementation, I guess.
类别
在 帮助中心 和 File Exchange 中查找有关 Resizing and Reshaping Matrices 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
