This is a static copy of a profile reportHome
nanmean (18174 calls, 1.302 sec)
Generated 05-Nov-2014 07:53:52 using cpu time.
function in file /usr1/opt/matlab/7.13/toolbox/stats/stats/nanmean.m
Copy to new window for comparing multiple runs
Parents (calling functions)
Function Name | Function Type | Calls |
skewness | function | 18174 |
Lines where the most time was spent
Line Number | Code | Calls | Total Time | % Time | Time Plot |
28 | n = sum(~nans,dim); | 18174 | 0.371 s | 28.5% |  |
31 | m = sum(x,dim) ./ n; | 18174 | 0.220 s | 16.9% |  |
17 | nans = isnan(x); | 18174 | 0.200 s | 15.4% |  |
18 | x(nans) = 0; | 18174 | 0.140 s | 10.8% |  |
29 | n(n==0) = NaN; % prevent divid... | 18174 | 0.090 s | 6.9% |  |
All other lines | | | 0.280 s | 21.5% |  |
Totals | | | 1.302 s | 100% | |
Children (called functions)
No childrenCode Analyzer results
No Code Analyzer messages.Coverage results
[ Show coverage for parent directory ]
Total lines in function | 32 |
Non-code lines (comments, blank lines) | 21 |
Code lines (lines that can run) | 11 |
Code lines that did run | 8 |
Code lines that did not run | 3 |
Coverage (did run/can run) | 72.73 % |
Function listing
time calls line
1 function m = nanmean(x,dim)
2 %NANMEAN Mean value, ignoring NaNs.
3 % M = NANMEAN(X) returns the sample mean of X, treating NaNs as missing
4 % values. For vector input, M is the mean value of the non-NaN elements
5 % in X. For matrix input, M is a row vector containing the mean value of
6 % non-NaN elements in each column. For N-D arrays, NANMEAN operates
7 % along the first non-singleton dimension.
8 %
9 % NANMEAN(X,DIM) takes the mean along dimension DIM of X.
10 %
11 % See also MEAN, NANMEDIAN, NANSTD, NANVAR, NANMIN, NANMAX, NANSUM.
12
13 % Copyright 1993-2004 The MathWorks, Inc.
14 % $Revision: 1.1.8.1 $ $Date: 2010/03/16 00:15:50 $
15
16 % Find NaNs and set them to zero
0.20 18174 17 nans = isnan(x);
0.14 18174 18 x(nans) = 0;
19
0.05 18174 20 if nargin == 1 % let sum deal with figuring out which dimension to use
21 % Count up non-NaNs.
22 n = sum(~nans);
23 n(n==0) = NaN; % prevent divideByZero warnings
24 % Sum up non-NaNs, and divide by the number of non-NaNs.
25 m = sum(x) ./ n;
0.08 18174 26 else
27 % Count up non-NaNs.
0.37 18174 28 n = sum(~nans,dim);
0.09 18174 29 n(n==0) = NaN; % prevent divideByZero warnings
30 % Sum up non-NaNs, and divide by the number of non-NaNs.
0.22 18174 31 m = sum(x,dim) ./ n;
0.06 18174 32 end
Other subfunctions in this file are not included in this listing.