MATLAB: Finding strings in a 21 x 1 cell array.

cell arrayismember

I have a cell array that looks like this:newsequence =
'CGT'
'GAC'
'AGT'
'CCT'
'CTC'
'CTT'
'TAC'
'CGA'
'AAG'
'GGA'
'AGA'
'ATA'
'AAA'
'GTG'
'GCG'
'TGA'
'TGC'
'ATT'
'ACG'
'CCT'
'GCA'
I am interested in finding the location of 'TAC'. When I use this function: found=strfind(newsequence,'TAC'); I end up with a cell array with all zeros and a 1 in the 7th row. I want it to display a 7 because that is the location of 'TAC', but I can't seem to figure it out.

Best Answer

newsequence = {'CGT'
'GAC'
'AGT'
'CCT'
'CTC'
'CTT'
'TAC'
'CGA'
'AAG'
'GGA'
'AGA'
'ATA'
'AAA'
'GTG'
'GCG'
'TGA'
'TGC'
'ATT'
'ACG'
'CCT'
'GCA'};
mask=strcmpi(newsequence ,'TAC');
rows=find(mask)
rows =
7
or you could combine both command in one as:
rows=find( strcmpi(newsequence ,'TAC') )