finding number of a column in a cell (column that contains a specified string)

3 次查看(过去 30 天)
how could it be done for finding first which array of a cell is equal a specified string and in second, what is number of column that contains this string
for example:
CELL={'a','b','c','d','e','f',...}
finding 'a' in CELL?(which row and column)

采纳的回答

Fangjun Jiang
Fangjun Jiang 2011-9-21
CELL={'a','b','c';'d','e','f'};
[Row,Col]=ind2sub(size(CELL),find(ismember(CELL,'e')))
or
[Row,Col]=ind2sub(size(CELL),find(strcmp(CELL,'e')))
  5 个评论

请先登录,再进行评论。

更多回答(2 个)

Harry MacDowel
Harry MacDowel 2011-9-21
find(char(CELL)=='a')
Does that help?
  4 个评论

请先登录,再进行评论。


Grzegorz Knor
Grzegorz Knor 2011-9-21
See in documentation:
doc strfind
strfind(CELL,'a')
  5 个评论
Jan
Jan 2011-9-21
I definitely prefer Grzegorz's solution in the comment above:
find(strcmp(C, 'a'))

请先登录,再进行评论。

类别

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