Alternatives to nanmean?

24 Ansichten (letzte 30 Tage)
ZH
ZH am 18 Jul. 2020
Kommentiert: Walter Roberson am 18 Jul. 2020
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.

Antworten (1)

KSSV
KSSV am 18 Jul. 2020
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 Kommentar
Walter Roberson
Walter Roberson am 18 Jul. 2020
The mean() 'omitnan' option is what I would recommend these days, provided that your MATLAB is new enough to have it.

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu MATLAB finden Sie in Help Center und File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by