Finding Maximum Value of a Table/Categorical Array
5 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Claire Hollow
am 10 Jun. 2020
Kommentiert: Paresh yeole
am 10 Jun. 2020
Hello! I have a question I can not get past. I have a 23000x1 table (named TMAX). It is a categorical array so it is mostly numbers but where the data is missing it is filled in with 'NA'. I am simply just looking to find the maximum value in the table. I did try
max(tmax);
but I get the error
Error using max
Invalid data type. First argument must be
numeric or logical.
I am not how to get past the NA's in there. Would even be open to switching them to NaN, whatever is simplest. Thank you in advance for the help!
0 Kommentare
Akzeptierte Antwort
Paresh yeole
am 10 Jun. 2020
Bearbeitet: Paresh yeole
am 10 Jun. 2020
first convert categorical to numeric array :
tmax = str2double(cellstr(tmax));
tmax(tmax == 'NA') = NaN;
max(tmax)
convert the 'NA' into NaN.
max function by default ignores the NaN values
2 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Data Type Conversion 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!