fft2 function in matlab
Ältere Kommentare anzeigen
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
Akzeptierte Antwort
Weitere Antworten (2)
Dr. Seis
am 30 Dez. 2011
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 Kommentare
Dr. Seis
am 30 Dez. 2011
Incidentally, do you understand why I am multiplying things by "dt" (in the 1D example) and "dx*dt" (in the 2D example)?
ddd
am 30 Dez. 2011
Dr. Seis
am 30 Dez. 2011
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
am 4 Apr. 2018
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
am 2 Dez. 2019
Bearbeitet: Kristian Torres
am 2 Dez. 2019
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
am 29 Sep. 2021
0 Stimmen
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.
Kategorien
Mehr zu Resizing and Reshaping Matrices finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
