search for string array index

I have a very big string array to search but it is in this format:
x=['a b c0 d';
'a b e1 f';
'a x d1 f';]
how can i efficiently search for the row index which has the letter 'a' in position 1 and the letter 'e1' in position 5:6. In this case the index is 2
Thanks. -S

Respuestas (1)

Matt Fig
Matt Fig el 15 de Nov. de 2012
Editada: Matt Fig el 15 de Nov. de 2012

0 votos

That example fails...
But let's try this one:
x=['a b c0 d';'a b e1 f';'a x d2 f';'m b e1 f';'a b e1 f'];
find(x(:,1)=='a' & x(:,5)=='e' & x(:,6)=='1')

2 comentarios

Sam
Sam el 15 de Nov. de 2012
sorry just correct the example Thanks Matt
Matt Fig
Matt Fig el 15 de Nov. de 2012
See my example, and solution.

Iniciar sesión para comentar.

Categorías

Más información sobre Characters and Strings en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

Sam
el 15 de Nov. de 2012

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by