Find cells with specific condition
1 回表示 (過去 30 日間)
古いコメントを表示
Hi everyone,
As the attachment, there is a cell array. I want to find specific cells as below:
Con1= {11 2}; Con2= {12 1};
Now, I can select above cells as following code.
Con1= {11 2};
Con2= {12 1};
Con1incorrect = find (cellfun(@(x) isequal (x,Con1), condition(1,:)));
Con2incorrect = find (cellfun(@(x) isequal (x,Con2), condition(1,:)));
But, I only want to select those cells that with following specific cells like Correctcon1 = {11 1} or Correctcon2 = {12 2},
How can I do that?
0 件のコメント
採用された回答
dpb
2020 年 10 月 24 日
First of all, not all elements of condition contain two elements so you'll have to special-case those or fix that anomaly. Use a NaN or something else for missing value indicator would be one way.
If do that, then there's no need for cell array at all; then just use
match=[11 1]; % wanted matching pattern
isMatch=ismember(condition,match,'rows'); % find matching indices in fixed condition array
0 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Creating and Concatenating Matrices についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!