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

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

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


Revision 1.3 - (hide annotations) (download)
Wed Jun 12 14:59:43 2002 UTC (21 years, 3 months ago) by adcroft
Branch: MAIN
CVS Tags: checkpoint46n_post, checkpoint51k_post, checkpoint47e_post, checkpoint52l_pre, hrcube4, hrcube5, checkpoint46l_post, checkpoint46g_pre, checkpoint47c_post, checkpoint50c_post, checkpoint46f_post, checkpoint52d_pre, checkpoint48e_post, checkpoint50c_pre, checkpoint46b_post, checkpoint52j_pre, checkpoint51o_pre, checkpoint51l_post, checkpoint48i_post, checkpoint46l_pre, checkpoint52l_post, checkpoint52k_post, checkpoint51, checkpoint50, checkpoint53, checkpoint52, checkpoint50d_post, checkpoint52f_post, checkpoint50b_pre, checkpoint51f_post, checkpoint48b_post, checkpoint51d_post, checkpoint48c_pre, checkpoint47d_pre, checkpoint51t_post, checkpoint51n_post, checkpoint52i_pre, hrcube_1, hrcube_2, hrcube_3, checkpoint51s_post, checkpoint47a_post, checkpoint48d_pre, checkpoint51j_post, checkpoint47i_post, checkpoint52e_pre, checkpoint52e_post, checkpoint51n_pre, checkpoint47d_post, checkpoint46d_pre, checkpoint48d_post, checkpoint48f_post, checkpoint45d_post, checkpoint52b_pre, checkpoint46j_pre, checkpoint51l_pre, checkpoint52m_post, checkpoint48h_post, checkpoint51q_post, checkpoint51b_pre, checkpoint46a_post, checkpoint47g_post, checkpoint52b_post, checkpoint52c_post, checkpoint46j_post, checkpoint51h_pre, checkpoint46k_post, checkpoint48a_post, checkpoint50f_post, checkpoint50a_post, checkpoint50f_pre, checkpoint52f_pre, checkpoint47j_post, checkpoint53c_post, branch-exfmods-tag, branchpoint-genmake2, checkpoint46e_pre, checkpoint51r_post, checkpoint48c_post, checkpoint46b_pre, checkpoint51i_post, checkpoint51b_post, checkpoint51c_post, checkpoint46c_pre, checkpoint53a_post, checkpoint46, checkpoint47b_post, checkpoint46h_pre, checkpoint52d_post, checkpoint46m_post, checkpoint46a_pre, checkpoint50g_post, checkpoint46g_post, checkpoint52a_pre, checkpoint50h_post, checkpoint52i_post, checkpoint50e_pre, checkpoint50i_post, checkpoint51i_pre, checkpoint52h_pre, checkpoint52j_post, checkpoint47f_post, checkpoint50e_post, checkpoint46i_post, checkpoint46c_post, branch-netcdf, checkpoint50d_pre, checkpoint52n_post, checkpoint53b_pre, checkpoint46e_post, checkpoint51e_post, checkpoint47, checkpoint48, checkpoint49, checkpoint46h_post, checkpoint51o_post, checkpoint51f_pre, checkpoint48g_post, checkpoint53b_post, checkpoint47h_post, checkpoint52a_post, checkpoint51g_post, ecco_c52_e35, checkpoint46d_post, checkpoint50b_post, checkpoint51m_post, checkpoint53d_pre, checkpoint51a_post, checkpoint51p_post, checkpoint51u_post
Branch point for: branch-exfmods-curt, branch-genmake2, branch-nonh, tg2-branch, netcdf-sm0, checkpoint51n_branch
Changes since 1.2: +4 -2 lines
Tidied up multi-dimensional stuff - thanks to tip from Martin Losch.

1 adcroft 1.2 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 adcroft 1.3 % $Header: /u/gcmpack/models/MITgcmUV/utils/matlab/stats.m,v 1.2 2001/05/29 14:01:41 adcroft Exp $
17    
18     A=A(:);
19 adcroft 1.2
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 adcroft 1.3 nZ=sum(~isfinite(A));
31 adcroft 1.2 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