Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Matlab's nanmean( ) function not working with dimensions other than 1

Take this example from the mathworks help of nanmean():

 X = magic(3);
X([1 6:9]) = repmat(NaN,1,5)

X =

   NaN     1   NaN
     3     5   NaN
     4   NaN   NaN

>> y = nanmean(X,2)
??? Error using ==> nanmean
Too many input arguments.

Why is it showing error even when the docs say the mean can be taken in any dimension dim of X as y = nanmean(X,dim)? Thanks.


1 Answers

I run exactly the code you have and I get no error. In particlar here is what I ran:

>> X = magic(3);
X([1 6:9]) = repmat(NaN,1,5)

X =

   NaN     1   NaN
     3     5   NaN
     4   NaN   NaN

>> y = nanmean(X,2)

y =

     1
     4
     4


>> which nanmean
C:\Program Files\MATLAB\R2010b\toolbox\stats\stats\nanmean.m

The only thing I can think of is that you have a different version of nanmean.m on your path. Try a which nanmean and see if it points into the stats toolbox.

like image 152
mwengler Avatar answered Dec 07 '25 13:12

mwengler



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!