MATLAB: Comparing and locating string values

indexlocationstring

I have a x=1×10 string of colors and the user enters a a=1×3 string of colors. Im trying to get the index of the location in the x-variable. How can i achieve that?
% my code
x=["Brown","Blue","Red","Orange","Purple","Black","Yellow","White"];
% User input
a=["Brown","Red"];
% I try this but it does not work
idx=strcmpi(a(1:2),x);

Best Answer

Please try following command.
ret = find(ismember(x,a))