Find Row and Column in Cell Array

11 ビュー (過去 30 日間)
Alex Young
Alex Young 2019 年 9 月 5 日
コメント済み: Alex Young 2019 年 9 月 5 日
I am trying to matlab to output the row and column number for the location of a string, in this case 'Activity desc.'
Code:
table = {'test', 'ts', 'tst'; 'dvd', 'cd', 'tv'; 'type', 'Activity desc.', 'date'};
fnd = strfind(table,'Activity desc.');
test1 = find([fnd{:}] == 1);
test2 = find(cell2mat(cellfun(@(x) (isequal(x,1)), fnd, 'UniformOutput', false)));
test1 = 1
test2 = 6
This is the closest i've come from what I have found so far.

採用された回答

madhan ravi
madhan ravi 2019 年 9 月 5 日
編集済み: madhan ravi 2019 年 9 月 5 日
Never name a variable table because it will shadow the inbuilt function.
[row,column] = find(strcmp(TAble,'Activity desc.'))
[row,column]=find(ismember(TAble,'Activity desc.')) % if you're using version prior to strcmp() was introduced
  1 件のコメント
Alex Young
Alex Young 2019 年 9 月 5 日
Thanks!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeString Parsing についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by