MATLAB: STRCMP in a loop

arrayloopstrcmp

I have a variable number of strings stored in an array. I want to compare each of those strings with a cell, and if the cell does not match any of the strings in the array, I want to delete it.
I'm not quite sure of the syntax. I know I can find the number by using length, but I can not do something like:
for j=1:length(match)
for i=1:length(compare_strings)
if strcmp(compare_strings(i),match(j))==0
compare_strings(i)=[];
end
end
end
It need to be more along the lines of:
if (strcmp(compare_strings(i),match(1))==0 && strcmp(compare_strings(i),match(2))==0 && strcmp(compare_strings(i),match(3))==0)
compare_strings(i)=[];
end
I need to check all of them at once, otherwise I may delete something that doesn't match the first, but matches one of the next. Any thought on the approach?

Best Answer

Use ismember()