search for string array index

3 次查看(过去 30 天)
Sam
Sam 2012-11-15
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

回答(1 个)

Matt Fig
Matt Fig 2012-11-15
编辑:Matt Fig 2012-11-15
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 个评论
Sam
Sam 2012-11-15
sorry just correct the example Thanks Matt
Matt Fig
Matt Fig 2012-11-15
See my example, and solution.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Characters and Strings 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by