How to replace -999 values with NaN in a Matlab table?
Mostra commenti meno recenti
I have a Matlab table T1, with columns like the below:
T1.year
T1.month
T1.day
T1.var1
T1.var2
...
Some of its columns are numerical and some of them are strings. For the numerical columns, there could be some -999 values in some of the columns to indicate NaN values.
Is it possible to replace all of the -999 values with NaN values, without specifying each of the columns?
I wish I could do someting as simple as that?
T1(T1==-999) = NaN
Like I do in a column data.
2 Commenti
Walter Roberson
il 13 Ott 2020
Are you reading from a text file? If so then use 'TreatAsMissing', '-999' option when you do the readtable()
Leon
il 13 Ott 2020
Risposta accettata
Più risposte (1)
Walter Roberson
il 13 Ott 2020
T1 = convertvars(T1, @isnumeric, @no999);
function x = no999(x)
x(x==-999) = nan;
end
1 Commento
Leon
il 13 Ott 2020
Categorie
Scopri di più su Calendar in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!