MATLAB: Finding the index of a string within an array of strings

arraysindexingstrings

I have an array composed of strings '0' 'P' 'E' and 'M' I am trying to find the index of the string 'P' within the array but the current lines I am using
staPlaLoc = find(maGen == 'P');
(wherein staPlaLoc is the index of 'P' within the array maGen) returns the following
Error using subsindex Function 'subsindex' is not defined for values of class 'string'.

Best Answer

May be this is what you want?
find(strcmp({'0' 'P' 'E' 'M'},'P'))