/[MITgcm]/MITgcm_contrib/gael/matlab_class/@gcmfaces/mean.m
ViewVC logotype

Contents of /MITgcm_contrib/gael/matlab_class/@gcmfaces/mean.m

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.3 - (show annotations) (download)
Mon Feb 8 13:19:21 2016 UTC (9 years, 5 months ago) by gforget
Branch: MAIN
CVS Tags: checkpoint65x, checkpoint65v, checkpoint65w, checkpoint65t, checkpoint65u, checkpoint66f, checkpoint66e, checkpoint66d, checkpoint66c, checkpoint66b, checkpoint66a, checkpoint66o, HEAD
Changes since 1.2: +13 -6 lines
- add DIM=0 option to operate on dimensions 1 and 2 jointly

1 function r = mean(p,varargin)
2 % MEAN(p,varargin)
3 %
4 %overloaded gcmfaces mean function :
5 % 1) if single gcmfaces argument, then returns the global mean over all faces
6 % 2) if more than one argument, then simply calls double mean function for
7 % each face data, passing over the other arguments
8
9 if nargin==1;
10 tmp1=[];
11 for iFace=1:p.nFaces;
12 iF=num2str(iFace);
13 eval(['tmp1=[tmp1;p.f' iF '(:)];']);
14 end;
15 r=mean(tmp1);
16 return;
17 end;
18
19 if varargin{1}>0;
20 r=p;
21 for iFace=1:r.nFaces;
22 iF=num2str(iFace);
23 eval(['r.f' iF '=mean(p.f' iF ',varargin{:});']);
24 end;
25 else;
26 tmp1=convert2gcmfaces(p);
27 [n1,n2,n3,n4]=size(tmp1);
28 tmp1=reshape(tmp1,n1*n2,n3,n4);
29 r=mean(tmp1,1);
30 end;
31

  ViewVC Help
Powered by ViewVC 1.1.22