Change string words to number in table
5 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Dion Theunissen
le 15 Oct 2021
Réponse apportée : Chunru
le 15 Oct 2021
Hi,
I have a table where one column contains words like 'Clear', ' Clouds' and 'Rain'.
I want to replace those for values like 1,2 and 3.
Anyone who can help me with this?
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/768046/image.png)
0 commentaires
Réponse acceptée
Chunru
le 15 Oct 2021
% Assume the column has the data
x.omst=["Clouds"; "Rain"; "Clear"]
% You can use the categorical data
x.omst = categorical(x.omst);
disp(x.omst)
% Or numbers
x.omst = double(categorical(x.omst));
disp(x.omst)
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Characters and Strings dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!