How do I look up a string in a struct and assign the number value that is associated with the string
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
Akzeptierte Antwort
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Structures finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!