]> Creatis software - CreaPhase.git/blob - utilities_LW/ssquare1.m
Useful functions for simulations (created by LW, free to use)
[CreaPhase.git] / utilities_LW / ssquare1.m
1 %# ssq=ssquare2(beta,f,g) returns sin(pi*beta*(f^2+g^2))
2 %# beta is equal to lambda*D/l^2, i.e. the Fresnelnumber
3 %# for the complete spectrum (from 0 to fsample)
4 %# f_isall = 0
5 %# only f and g from 0 to fsample/2 should be given, the other part is 
6 %# calculated using the periodicity in frequency-space
7 %# f_isall = 1
8 %# complete frequency range is given
9 %# allows for astigmatism (5th argument)
10
11 function ssq=ssquare1(betah,f,varargin)
12
13 f_isall = 0;
14 switch nargin
15 case 3
16     f_isall = varargin{1};
17 end 
18
19 ssq=sin((pi*betah)*f.^2);
20
21 if (f_isall~=1)
22     [n m]=size(f);
23     n=n-1;
24     m=m-1;
25     ssq=cat(2,cat(1,ssq,flipdim(ssq(2:n,:,:),1)),cat(1,flipdim(ssq(:,2:m,:),2),flipdim(flipdim(ssq(2:n,2:m,:),1),2)));
26 end
27
28 end