MATLAB: Match a categorical array in a loop

find

Hi,
isequal(AgeState,StateState(i));
is returning a 0 although I can see visually that AgeState which is a categorical array matches StateState(i) at least 13 times. How can I find which rows in Agetate match StateState(i)?

Best Answer

any(ismember(AgeState, StateState(i)), 2)
or
all(ismember(AgeState, StateState(i)), 2)
depending on whether "which rows in Agetate match StateState(i)" is intended to refer to there being at least one element of the row that matches, or if it is intended to refer to all elements in the row matching.