Fourier Transform changes when resolution changes
Show older comments
Hello all!
Quite new to MATLAB, but hoping to be able to get some help with a model I am trying to build. The challenge is to be able to simulate the 1D diffraction pattern based on the position of atoms in a thin film. It needs to be done numerically (as opposed to analytically). We have (I think!) succesfully made a model in real space positioning "atoms" (1/dx pulses at specific locations, where dx is the resolution) in the locations we want, and then are using FFT to generate the diffraction pattern. The problem is, when the resolution changes from, say 1 to 0.1, the diffraction pattern changes. This does not seem to make physical sense, and by doing an analytic Fourier transform by hand for an almost identical problem, I don't see this behaviour. I wonder if anyone can explain this to us, and help us fix it! I think it is something to do with the length scale not being constant and that not being passed to the FFT, i.e. at a resolution 10 times larger than before, point a is 10 times further along the array. I have attached the code below, and screenshots of the problem.
Thank you!
Resolution of 1

Resolution of 0.1

%%Define parameters
dx = .1; % Resolution
x_size = 1000; % Bigger value makes more infinite lattice
%%Set up infinte lattice
x_points = round(x_size/dx); % Number of points on the x-axis
x = zeros(x_points,2);
for n = 1:x_points
x(n,1) = dx * n;
atom_point = round(atom_point_equation(x(n,1),dx)/dx); % Get index for atom positions
if(atom_point>0 && atom_point<=x_points)
x(atom_point,2) = 1/dx; % Simulate dirac delta function
end
end
figure('units','normalized','outerposition',[0 0 1 1])
subplot(2,2,1)
plot(x(:,1),x(:,2)); % Plot the atom positions
xlabel(['Length (' char(197) ')'])
ylabel('Instensity (arb.)')
title('Position of atoms on infinite lattice')
%%Do Fourier Transform of infinite lattice
ft = zeros(x_points,2);
ft(:,1) = (2*pi/dx) * (1:x_points)/x_points;
ft(:,2) = abs(fft(x(:,2))/x_points);
subplot(2,2,2)
plot(ft(:,1),ft(:,2)); % Plot the atom positions
%xlim([0 2*pi])
xlabel(['Q'])
ylabel('Instensity (arb.)')
title('Diffraction Pattern of infinite lattice')
%%Set up top hat function (or equivalent) to define real lattice
for n = 1:x_points
x(n,2) = x(n,2) * top_hat(x(n,1),(x_size/2)); % Get value of top hat function at this location
end
subplot(2,2,3)
plot(x(:,1),x(:,2)); % Plot the atom positions
xlabel(['Length (' char(197) ')'])
ylabel('Instensity (arb.)')
title('Position of atoms with top hat-like function')
%%Do Fourier transform of real lattice
ft(:,2) = abs(fft(x(:,2))/x_points);
subplot(2,2,4)
plot(ft(:,1),ft(:,2)); % Plot the diffraction pattern
%xlim([0 2*pi])
xlabel(['Q'])
ylabel('Instensity (arb.)')
title('Diffraction Pattern of Real Lattice')
2 Comments
David Goodmanson
on 12 Oct 2016
Hello Thomas, unfortunately the links to the screenshots do not appear to work.
Star Strider
on 12 Oct 2016
Problem solved!
Answers (1)
David Goodmanson
on 12 Oct 2016
Edited: David Goodmanson
on 13 Oct 2016
I believe that all of the plots are correct. For an N-point fft, if dx and dQ are the spacings of the x and Q arrays (Q being 'ft' earlier in the code), these are related by
dx dQ = 2pi/N
Q_max = 2pi/dx
(this assumes the Q array is from 0 to Q_max). When you reduced dx by a factor of 10, Q_max got 10 times larger, as the plot shows. You get a lot more lines, but their spacing is still the same as it was. And there is no limit to Q_max. This is because of aliasing, or whatever equivalent way you want to look at it.
My apologies to Star Strider if his or her comment meant the entire issue was solved as opposed to getting access to the plots, which of course was essential.
Categories
Find more on Fourier Analysis and Filtering in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!