Alternatives to nanmean?
25 ビュー (過去 30 日間)
古いコメントを表示
How could I create a mean funtion that ignores NaN values?
I am trying to find the average of a column even with “NaN” values and nanmean requies extra downloads.
0 件のコメント
回答 (1 件)
KSSV
2020 年 7 月 18 日
Let A be your array which have NaN's.
% Remove the nan's first
A(isnan(A)) = [] ;
themean = mean(A) ;
Also read about mean function, it has an option to omitnans.
1 件のコメント
Walter Roberson
2020 年 7 月 18 日
The mean() 'omitnan' option is what I would recommend these days, provided that your MATLAB is new enough to have it.
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!