convert categorical to numeric
3 Kommentare
Akzeptierte Antwort
7 Kommentare
Weitere Antworten (5)
1 Kommentar
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 Kommentare
0 Kommentare
1 Kommentar
1 Kommentar
Siehe auch
Kategorien
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!