MATLAB: How to look up a string in a struct and assign the number value that is associated with the string

MATLABstructures

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

Best Answer

qualityNumber = VAL.qualityTypes.(quality)
Related Question