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

1 view (last 30 days)
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 on 21 Sep 2011
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')))
Fangjun Jiang on 21 Sep 2011
@Grzegorz, Good catch!
Hi Jan,
yes this the fastest that Fangjun told

Harry MacDowel on 21 Sep 2011
find(char(CELL)=='a')
Does that help?
Harry MacDowel on 21 Sep 2011
I corrected the answer up there.
now this error:
??? Error using ==> eq
Matrix dimensions must agree.

Grzegorz Knor on 21 Sep 2011
See in documentation:
doc strfind
strfind(CELL,'a')
Jan on 21 Sep 2011
I definitely prefer Grzegorz's solution in the comment above:
find(strcmp(C, 'a'))
Hi Jan
OK let me check