/[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.4 - (show annotations) (download)
Fri Jun 4 17:03:50 2004 UTC (20 years, 1 month ago) by adcroft
Branch: MAIN
CVS Tags: checkpoint57m_post, checkpoint57g_pre, checkpoint57s_post, checkpoint58b_post, checkpoint57b_post, checkpoint57g_post, checkpoint56b_post, checkpoint57y_post, checkpoint54d_post, checkpoint54e_post, checkpoint57r_post, checkpoint57d_post, checkpoint57i_post, checkpoint58, checkpoint55, checkpoint54, checkpoint57, checkpoint56, checkpoint58f_post, checkpoint57n_post, checkpoint58d_post, checkpoint58a_post, checkpoint57z_post, checkpoint54f_post, checkpoint58t_post, checkpoint55i_post, checkpoint58m_post, checkpoint57l_post, checkpoint57t_post, checkpoint55c_post, checkpoint57v_post, checkpoint57f_post, checkpoint53d_post, checkpoint57a_post, checkpoint57h_pre, checkpoint54b_post, checkpoint57h_post, checkpoint57y_pre, checkpoint55g_post, checkpoint58o_post, checkpoint57c_post, checkpoint58p_post, checkpoint58q_post, checkpoint55d_post, checkpoint58e_post, checkpoint54a_pre, checkpoint55d_pre, checkpoint57c_pre, checkpoint58r_post, checkpoint55j_post, checkpoint54a_post, checkpoint55h_post, checkpoint58n_post, checkpoint57e_post, checkpoint55b_post, checkpoint55f_post, checkpoint53g_post, checkpoint57p_post, checkpint57u_post, checkpoint57q_post, eckpoint57e_pre, checkpoint58k_post, checkpoint58v_post, checkpoint56a_post, checkpoint58l_post, checkpoint53f_post, checkpoint57h_done, checkpoint57j_post, checkpoint57f_pre, checkpoint58g_post, checkpoint58h_post, checkpoint56c_post, checkpoint58j_post, checkpoint57a_pre, checkpoint55a_post, checkpoint57o_post, checkpoint57k_post, checkpoint57w_post, checkpoint58i_post, checkpoint57x_post, checkpoint58c_post, checkpoint58u_post, checkpoint58s_post, checkpoint55e_post, checkpoint54c_post
Changes since 1.3: +7 -3 lines
New scripts and M6.5 compatibility issues

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 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