How do I look up a string in a struct and assign the number value that is associated with the string
1 view (last 30 days)
Show older comments
I have a struct where I specify strings that indicate certain quality levels for validation:
VAL.qualityTypes = struct('POOR', 1, 'FAIR', 2, 'GOOD', 3);
I have another variable ('quality') that contains one of these strings in a cell.
quality = 'GOOD'
What code would I use to obtain the number associated with the specific string, like so:
qualityNumber = 3
0 Comments
Accepted Answer
More Answers (0)
See Also
Categories
Find more on Structures in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!