Change string words to number in table
7 views (last 30 days)
Show older comments
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?
0 Comments
Accepted Answer
Chunru
on 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 Comments
More Answers (0)
See Also
Categories
Find more on Characters and Strings in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!