function dna
%
% MATLAB function from:
% "Elements of Modern X-ray Physics" by Jens Als-Nielsen and Des McMorrow
%
% Calculates: Fibre diffraction pattern from DNA

[x,y]=meshgrid(-11:0.2:11,-11:0.2:11);

iw=20;    %iw is the inverse width of a Bragg peak, here modelled as a Gaussian
z=zeros(size(x));
for il=-11:11
   z=z+ abs((1+exp(i*il*2*pi*0.125)).*besselj(abs(il),x)).^2.*exp(-iw*(y+il).^2);
end

pcolor(x,y,z)
shading interp

axis equal; axis([-11 11 -11 11]); caxis([-0.1 2]); box on
set(gca,'FontName','Times','FontSize',18,'Position',[0.15 0.15 0.7 0.7])

colormap(1-gray)
caxis([-0.05 0.3])
set(gca,'dataaspectratio',[1*34/20 1 1])