]> Creatis software - CreaPhase.git/blobdiff - utilities_LW/csquare1.m
Useful functions for simulations (created by LW, free to use)
[CreaPhase.git] / utilities_LW / csquare1.m
diff --git a/utilities_LW/csquare1.m b/utilities_LW/csquare1.m
new file mode 100644 (file)
index 0000000..4783def
--- /dev/null
@@ -0,0 +1,40 @@
+## Copyright (C) 2015 Loriane Weber
+## 
+## This program is free software; you can redistribute it and/or modify
+## it under the terms of the GNU General Public License as published by
+## the Free Software Foundation; either version 3 of the License, or
+## (at your option) any later version.
+## 
+## This program is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+## GNU General Public License for more details.
+## 
+## You should have received a copy of the GNU General Public License
+## along with Octave; see the file COPYING.  If not, see
+## <http://www.gnu.org/licenses/>.
+
+## csquare1
+
+## Author: Loriane Weber <lweber@rnice7-0103>
+## Created: 2015-06-04
+
+function csq=csquare1(betah,f,varargin)
+
+f_isall = 0;
+switch nargin
+case 3
+    f_isall = varargin{1};
+end 
+
+csq=cos((pi*betah)*f.^2);
+
+if (f_isall~=1)
+    [n m]=size(f);
+    n=n-1;
+    m=m-1;
+    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)));
+end
+
+
+end