/[MITgcm]/MITgcm_contrib/high_res_cube/matlab-grid-generator/bin/stats.m
ViewVC logotype

Annotation of /MITgcm_contrib/high_res_cube/matlab-grid-generator/bin/stats.m

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


Revision 1.1 - (hide annotations) (download)
Tue Nov 11 18:08:08 2003 UTC (21 years, 8 months ago) by cnh
Branch point for: MAIN, initial
Initial revision

1 cnh 1.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: /u/gcmpack/models/MITgcmUV/utils/matlab/stats.m,v 1.3 2002/06/12 14:59:43 adcroft Exp $
17    
18     A=A(:);
19    
20     %ii=find(A~=0);
21     ii=find(isfinite(A));
22     if isempty(ii)
23     ii=1;
24     end
25     sZ=prod(size(A));
26     minA=min(A(ii));
27     maxA=max(A(ii));
28     meanA=mean(A(ii));
29     sdA=sqrt( mean( (A(ii)-meanA).^2 ) );
30     nZ=sum(~isfinite(A));
31     switch max(nargout)
32     case {0}
33     disp( ...
34     sprintf('Min %0.5g Max %0.5g Mean %0.5g SD %0.5g NaN %i/%i',...
35     minA,maxA,meanA,sdA,nZ,sZ) );
36     case {1}
37     varargout(1)={minA};
38     case {2}
39     varargout(1)={minA};
40     varargout(2)={maxA};
41     case {3}
42     varargout(1)={minA};
43     varargout(2)={maxA};
44     varargout(3)={meanA};
45     case {4}
46     varargout(1)={minA};
47     varargout(2)={maxA};
48     varargout(3)={meanA};
49     varargout(4)={sdA};
50     otherwise
51     error('Too many return arguments requested')
52     end

  ViewVC Help
Powered by ViewVC 1.1.22