/[MITgcm]/MITgcm_contrib/enderton/Diagnostics/DiagUtility/stats.m
ViewVC logotype

Contents of /MITgcm_contrib/enderton/Diagnostics/DiagUtility/stats.m

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


Revision 1.1 - (show annotations) (download)
Mon Jan 31 15:43:29 2005 UTC (20 years, 5 months ago) by enderton
Branch: MAIN
CVS Tags: HEAD
Error occurred while calculating annotation data.
 o Initial check in.

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/MITgcm/utils/matlab/stats.m,v 1.4 2004/06/04 17:03:50 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 rmsA=sqrt( mean( A(ii).^2 ) );
31 nZ=sum(~isfinite(A));
32 switch max(nargout)
33 case {0}
34 % disp( ...
35 % sprintf('Min %0.5g Max %0.5g Mean %0.5g SD %0.5g NaN %i/%i',...
36 % minA,maxA,meanA,sdA,nZ,sZ) );
37 disp( ...
38 sprintf('Min %0.5g Max %0.5g Mean %0.5g RMS %0.5g NaN %i/%i',...
39 minA,maxA,meanA,rmsA,nZ,sZ) );
40 case {1}
41 varargout(1)={minA};
42 case {2}
43 varargout(1)={minA};
44 varargout(2)={maxA};
45 case {3}
46 varargout(1)={minA};
47 varargout(2)={maxA};
48 varargout(3)={meanA};
49 case {4}
50 varargout(1)={minA};
51 varargout(2)={maxA};
52 varargout(3)={meanA};
53 varargout(4)={sdA};
54 otherwise
55 error('Too many return arguments requested')
56 end

  ViewVC Help
Powered by ViewVC 1.1.22