convert categorical to numeric
3 Commenti
Risposta accettata
7 Commenti
Più risposte (5)
1 Commento
Calling categorical is a data conversion, so
c = categorical([12 12 13])
completely throws away the numeric values. In general, there is no way to get them back unless you have saved them, any more than you can get back the original values from int8([1.1 2.2 3.3]). Calling categorical is a data conversion.
That being said, you can certainly save the unique numeric values, and then index into those using the categorical array:
n = uniqueNumericValues(c)
You can also call double on a categorical, but what you will get back are the category numbers, not the original numeric values.
But here's the question: if you need to convert back to the original numbers, and you are not using meaningful category names when converting from those numbers, why use categorical to begin with? There may be things you haven't mentioned.
4 Commenti
0 Commenti
1 Commento
1 Commento
Vedere anche
Categorie
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!