"Charlotte Chaze" <cchaze@udel.edu> wrote in message <o5be4n$ahb$1@newscl01ah.mathworks.com>...
> There's a surprisingly easy way! Since nanmean takes the mean of each column and then puts those means into an array, do nanmean multiple times until you have the desired number of values.
That is not a wise advise. Run this to see why you have to be careful about take the average of the average where the number of invalid elements are dispersed.
A=nan(100,100);
A(1,:)=1;
A(:,1)=1e6;
% Replace with nanmean with you have stats tbx
mean(mean(A,'omitnan'),'omitnan')
mean(mean(A','omitnan'),'omitnan')
mean(A(:),'omitnan')
> There's a surprisingly easy way! Since nanmean takes the mean of each column and then puts those means into an array, do nanmean multiple times until you have the desired number of values.
That is not a wise advise. Run this to see why you have to be careful about take the average of the average where the number of invalid elements are dispersed.
A=nan(100,100);
A(1,:)=1;
A(:,1)=1e6;
% Replace with nanmean with you have stats tbx
mean(mean(A,'omitnan'),'omitnan')
mean(mean(A','omitnan'),'omitnan')
mean(A(:),'omitnan')