Clear Filters
Clear Filters

Finding the below fft

2 views (last 30 days)
Amy Topaz
Amy Topaz on 29 Mar 2022
Edited: Amy Topaz on 3 Apr 2022
I have the fft result with which I need to perform the spatial frequency distribution in (um)-1 units and plot the spatial frequency spectrum for y=0.01,0.02,0.03,1. I need some idea how to proceed with that?

Accepted Answer

William Rose
William Rose on 29 Mar 2022
Edited: William Rose on 29 Mar 2022
[edited: correct typos, not in the code]
You are using the 2D FFT. The 2D FFT is appropriate for images or other 2D data in which there is a uniform grid spacing along the two independent variables. In this case, there are only 4 y-values, and they are unevenly spaced. Therefore I recommend doing the 1D FFT on the array Hy. This will compute the 1D FFT of each column of Hy. Since x varies along the rows of Hy, I take the FFT of the transpose of Hy. fft(Hy') returns a complex array whose columns are the FFTs of the rows of Hy. The absolute values of the complex numbers are the magnitudes of the Fourier transform.
%AmyTopazscript.m, modified by WCR, 2022-03-28
clear;
g = 1e-7;
dx=0.01;
x = -0.5:dx:0.5;
N=length(x);
df=1/(N*dx); %frequency interval for the FT
f=(0:N-1)*df; %frequency vector for the FT
y = [0.01*g 0.2*g 0.6*g g]';
Hy = (-1/2*pi)*(log((g/2 + x).^2 + (y).^2./(g/2 - x).^2 + (y).^2));
Z = fft(Hy');
%Plot results
figure;
subplot(211)
plot(x,Hy(1,:),'-k',x,Hy(2,:),'-r',x,Hy(3,:),'-g',x,Hy(4,:),'-b');
grid on; xlabel('x (\mum)'); ylabel('Hy(x)');
legend('0.01g','0.2g','0.6g','g');
subplot(212)
plot(f,abs(Z(:,1)),'-k',f,abs(Z(:,2)),'-r',f,abs(Z(:,3)),'-g',f,abs(Z(:,4)),'-b');
grid on; xlabel('Spatial frequency (\mum^-^1)'); ylabel('|FT(Hy)|');
xlim([0 N*df/2]); %plot FT up to Nyquist frequency
legend('0.01g','0.2g','0.6g','g');
Try the code above.

More Answers (0)

Categories

Find more on Graphics Performance in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!