Compare elements of cell array

1 ビュー (過去 30 日間)
Tha saliem
Tha saliem 2017 年 4 月 2 日
コメント済み: Tha saliem 2017 年 4 月 2 日
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.
  5 件のコメント
Tha saliem
Tha saliem 2017 年 4 月 2 日
Im really sorry I was using it through cell phone and i clicked on Accept answer at the time when i commented on that. I didn't even know that it was not accepted. Sorry for this. and thanks for your code it really helped. The main task is quite large and i am working on it from 4 to 5 weeks so it will be difficult for me to sum it up.

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

採用された回答

the cyclist
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);
  2 件のコメント
Tha saliem
Tha saliem 2017 年 4 月 2 日
Problem solved. Thanks alot for your help.

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

その他の回答 (0 件)

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by