]> Creatis software - CreaPhase.git/blob - utilities_LW/csquare1.m
Useful functions for simulations (created by LW, free to use)
[CreaPhase.git] / utilities_LW / csquare1.m
1 ## Copyright (C) 2015 Loriane Weber
2 ## 
3 ## This program is free software; you can redistribute it and/or modify
4 ## it under the terms of the GNU General Public License as published by
5 ## the Free Software Foundation; either version 3 of the License, or
6 ## (at your option) any later version.
7 ## 
8 ## This program is distributed in the hope that it will be useful,
9 ## but WITHOUT ANY WARRANTY; without even the implied warranty of
10 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11 ## GNU General Public License for more details.
12 ## 
13 ## You should have received a copy of the GNU General Public License
14 ## along with Octave; see the file COPYING.  If not, see
15 ## <http://www.gnu.org/licenses/>.
16
17 ## csquare1
18
19 ## Author: Loriane Weber <lweber@rnice7-0103>
20 ## Created: 2015-06-04
21
22 function csq=csquare1(betah,f,varargin)
23
24 f_isall = 0;
25 switch nargin
26 case 3
27     f_isall = varargin{1};
28 end 
29
30 csq=cos((pi*betah)*f.^2);
31
32 if (f_isall~=1)
33     [n m]=size(f);
34     n=n-1;
35     m=m-1;
36     csq=cat(2,cat(1,csq,flipdim(csq(2:n,:,:),1)),cat(1,flipdim(csq(:,2:m,:),2),flipdim(flipdim(csq(2:n,2:m,:),1),2)));
37 end
38
39
40 end