% Comparison of Gaussian, Lorentzian, and sech2 pulse shapes, showing
% that the sech2 pulse in intermediate between Gaussian and Lorentzian.
x=-10:.1:10;
p=0;
tau=2;
y=sech2pulse(x,p, tau);
plot(x,y,x,gaussian(x,0,1.77*tau), x,lorentzian(x,0,1.77*tau),'linewidth',2)
grid
legend('Sech2','Gaussian','Lorentzian')
title('Comparison of Gaussian, Lorentzian, and sech2 pulse shapes)')

function g = gaussian(x,pos,wid)
% g=gaussian(x,pos,wid)
%  gaussian peak centered on pos, half-width=wid
% x may be scalar, vector, or matrix,
% pos and wid both scalar
% T. C. O'Haver, 1988
%
% Examples: gaussian([0 1 2],1,2) gives
% result [0.5000    1.0000    0.5000]
% plot(gaussian([1:100],50,20)) displays
% gaussian band centered at 50 with width 20.
%
g = exp(-((x-pos)./(0.60056120439323.*wid)) .^2);
end

function g = lorentzian(x,position,width)
% lorentzian(x,position,width) Lorentzian function.
% where x may be scalar, vector, or matrix
% position and width scalar
% T. C. O'Haver, 1988
% Example: lorentzian([1 2 3],2,2) gives result [0.5 1 0.5]
g=ones(size(x))./(1+((x-position)./(0.5.*width)).^2);
end