Compare elements of cell array
1 ビュー (過去 30 日間)
表示 古いコメント
HI I have a 2D array like this:

and a cell array:

I want to search elements of cell array in 1st column of 2D array. Like 2nd row of cell array has 4 and 3, it is present in 1st column of 2D array, it should display both rows (and all other elements as zero).
Thanks in advance.
採用された回答
the cyclist
2017 年 4 月 2 日
M = [0 1
1 0
2 1
3 0
4 1
5 0
6 0];
C = {[];[4;3];[3;1;4];2;[1;3;2;4];5;5};
output = cellfun(@(x)M(sort(x),:),C,'UniformOutput',false);
その他の回答 (0 件)
参考
カテゴリ
Find more on Matrix Indexing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!