/[MITgcm]/MITgcm/utils/matlab/stats.m
ViewVC logotype

Contents of /MITgcm/utils/matlab/stats.m

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


Revision 1.1.2.1 - (show annotations) (download)
Fri Apr 13 18:28:23 2001 UTC (22 years, 1 month ago) by adcroft
Branch: pre38
CVS Tags: pre38tag1, pre38-close
Changes since 1.1: +50 -0 lines
Added RCS id's to routines.
Added re-gridding routine for cubed sphere.
Added "stats" routine.

1 function [varargout] = stats(A)
2 % stats(A) writes the basic statistics of the A to the terminal which
3 % are i) the minimum finite value
4 % ii) the maximum finite value
5 % iii) the mean of the finite values
6 % iv) the S.D. of the finite values ( RMS of [A-mean] )
7 % v) the fraction of non-finite elements excluded from calculations
8 %
9 % e.g.
10 % >> stats(topo)
11 % Min -4555 Max 0 Mean -2331.07 SD 1207.3441 N-Z 1024/1024
12 %
13 % [Min Max Mean SD]=stats(topo); returns the statistics in Min, Max,
14 % Mean and SD and does not write to the terminal.
15 %
16 % $Header: $
17
18 %ii=find(A~=0);
19 ii=find(isfinite(A));
20 if isempty(ii)
21 ii=1;
22 end
23 sZ=prod(size(A));
24 minA=min(A(ii));
25 maxA=max(A(ii));
26 meanA=mean(A(ii));
27 sdA=sqrt( mean( (A(ii)-meanA).^2 ) );
28 nZ=prod(sum(sum(sum(~isfinite(A)))));
29 switch max(nargout)
30 case {0}
31 disp( ...
32 sprintf('Min %0.5g Max %0.5g Mean %0.5g SD %0.5g NaN %i/%i',...
33 minA,maxA,meanA,sdA,nZ,sZ) );
34 case {1}
35 varargout(1)={minA};
36 case {2}
37 varargout(1)={minA};
38 varargout(2)={maxA};
39 case {3}
40 varargout(1)={minA};
41 varargout(2)={maxA};
42 varargout(3)={meanA};
43 case {4}
44 varargout(1)={minA};
45 varargout(2)={maxA};
46 varargout(3)={meanA};
47 varargout(4)={sdA};
48 otherwise
49 error('Too many return arguments requested')
50 end

  ViewVC Help
Powered by ViewVC 1.1.22