Compute Mode of values in array greater than 0

1 Ansicht (letzte 30 Tage)
Tyler Smith
Tyler Smith am 17 Sep. 2018
Kommentiert: Tyler Smith am 17 Sep. 2018
I need to compute the mode from values in my array (9x9 array) greater than 0. This is because I only care about the values greater than 0 and 0 will more often than not be the mode. Any suggestions would be great. Thanks!

Akzeptierte Antwort

Stephan
Stephan am 17 Sep. 2018
Bearbeitet: Stephan am 17 Sep. 2018
Hi,
here is a workaround using the properties of NaN :
A = [0 0 5; 0 0 0; 1 1 0;];
B=A;
B(A==0) = NaN;
res = mode(B);
disp(res)
Best regards
Stephan

Weitere Antworten (0)

Kategorien

Mehr zu Operators and Elementary Operations finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by