How to convert characters in a table into numbers
Show older comments
So i have a large table full of cloud cover codes from weather station reports. What I want to do is convert said codes into a corresponding number. For example, I want all 'CLR' reports to return a value of zero, 'FEW' to return a value of 1, and so forth. An example of the results I'm looking for:
'SCT' ---> 2
'OVC' ---> 4
'BKN' ---> 3
'CLR' ---> 0
4 Comments
Walter Roberson
on 6 Feb 2020
categorical() with the three input version permits you to specify a set of input strings in the second parameter and a list of corresponding values in the third parameter.
Or use the two output form of ismember.
Erik Michael
on 6 Feb 2020
Adam Danz
on 6 Feb 2020
Duplicates shouldn't be a problem. What's the full copy-pasted error message?
Erik Michael
on 6 Feb 2020
Accepted Answer
More Answers (0)
Categories
Find more on Data Type Conversion 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!