Axes after 2D fft

46 次查看(过去 30 天)
mm99
mm99 2020-1-12
回答: Meg Noah 2020-1-12
Hi!
I've done the 2d fft using fft2 of the matrix 30000x5000, which contains numerical model responses and time of this responses after signal excitation. How can I make the axes correct , change x into frequency and y into wave-number? The attached figure is zoomed, but before zooming the axes show 30000 and 5000.

回答(1 个)

Meg Noah
Meg Noah 2020-1-12
Some great online references are in the matlab code. Whenever I post links at the top of an answer, the answer gets flagged as spam, but then they encourage you to post reference links? Oh well. Here's some code to help with this problem:
% Online references for FFT's
% https://www.gaussianwaves.com/2015/11/interpreting-fft-results-complex-dft-frequency-bins-and-fftshift/
% https://blogs.uoregon.edu/seis/wiki/unpacking-the-matlab-fft/
dx_m = 0.5; % [m]
dy_m = 0.5; % [m]
% generate fractal texture for this spatial frame
MaxLevel = 6; % size of image is 2^MaxLevel+1
seed = 8675309; % seed enables repeatability
H = 0.5; % Hurst parameters a values between 0 and 1
FractalImage = midpoint(MaxLevel,H,seed);
N = 2.0^MaxLevel;
% spatial coordinates
X1D = dx_m.*[-N/2:N/2];
Y1D = dy_m.*[-N/2:N/2];
% visualize spatial data
figure('Color','white');
subplot(2,1,1)
imagesc(X1D,Y1D,FractalImage,[-3 3]);
title({'Fractional Brownian Motion';['Hurst =' num2str(H) ...
' Fractal Dimension =' num2str(3-H)]},'fontsize',12);
axis equal
axis tight
colormap(bone);
colorbar
set(gca,'fontweight','bold');
xlabel('X [m]'); ylabel('Y [m]');
% now to show the power spectrum
% with frequency space grid
ny = N;
nx = N;
dfy = 1/(ny*dy_m);
dfx = 1/(nx*dx_m);
fy = (-0.5/dy_m:dfy:(0.5/dy_m-1/(ny*dy_m)));
fx = (-0.5/dx_m:dfx:(0.5/dx_m-1/(nx*dx_m)));
FFT_FractalImage = fft2(FractalImage);
subplot(2,1,2)
imagesc(fx,fy,20*log10(abs(fftshift(FFT_FractalImage))));
axis equal; axis tight; colormap(bone); colorbar
set(gca,'fontweight','bold');
xlabel('Frequency [1/m]'); ylabel('Frequency [1/m]');
title('FFT2D Output','fontsize',12);
To run the code, you can download the midpoint function here (thank you if you do!):
FFTAxes.png

类别

Help CenterFile Exchange 中查找有关 Propagation and Channel Models 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by