Find specific cell in another cells

1 回表示 (過去 30 日間)
Ting-Yu Chueh
Ting-Yu Chueh 2019 年 4 月 21 日
編集済み: Ting-Yu Chueh 2019 年 4 月 21 日
Hi everyone,
Attachment is my file.
I would like to know the locations of this cells containes a specific cell-{21 31 1}
I try to use like below:
Match = {21 31 1};
CorrectMatch = find (cellfun(@(x) isequal (x,Match), condition(1,:)));
but it return 0.
Could any one help me?
  2 件のコメント
madhan ravi
madhan ravi 2019 年 4 月 21 日
編集済み: madhan ravi 2019 年 4 月 21 日
Ting-Yu Chueh
Ting-Yu Chueh 2019 年 4 月 21 日
編集済み: Ting-Yu Chueh 2019 年 4 月 21 日
Thnaks. That's what I asked before.
In that case,
condition = { {21 31 1}, {22 32 2}, {21 31 }, {22 32 1} };
% Define what we want to find
match = {21 31 1};
% Instantiate output vector of where matches were found.
CorrectMatch = find (cellfun(@(x) isequal (x,match), condition(1,:)));
It work out.
But, in my real data, it failed. I don't know what problems in this method or data.

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

採用された回答

Walter Roberson
Walter Roberson 2019 年 4 月 21 日
match = {21 31 1}
does not exist in your actual condition variable. Your actual condition is a cell array of cell arrays of character vectors such as {'21' '31' '1'}
match = {21 31 1};
mm = cell2mat(match); %eg [21 31 1]
CorrectMatch = find( cellfun(@(c) isequal(str2double(c), mm),condition) );
  1 件のコメント
Ting-Yu Chueh
Ting-Yu Chueh 2019 年 4 月 21 日
編集済み: Ting-Yu Chueh 2019 年 4 月 21 日
It works out. Many thanks!!

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

その他の回答 (0 件)

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by