フィルターのクリア

Obtain cell according to a corresponding value

1 回表示 (過去 30 日間)
Dimitris Kokkinos
Dimitris Kokkinos 2014 年 12 月 4 日
編集済み: Azzi Abdelmalek 2014 年 12 月 4 日
Hello everyone!I have 2 cell arrays. The first one is 5x2:
A={[1;2;3;4;5] 3;[12;13;14] 2;[1;2;3;4;8;9;10;22;23;24] 6;[4;5;6;8;9] 4;[5;6;7] 6};
The second one is 6x1
B={[32;21;13];[1;2;35];[5;6;7;8;9;0;2;3];[2];[1;3;5;7;9];[5;6;7]}
What I need is to create another cell array which will contain cells from array B selected and sorted according to A(:,2). The extracted result should be:
R={[5;6;7;8;9;0;2;3];[1;2;35];[5;6;7];[2];[5;6;7]}
R(1)=B(3)
R(2)=B(2)
R(3)=B(6)
R(4)=B(4)
R(5)=B(6)

採用された回答

Azzi Abdelmalek
Azzi Abdelmalek 2014 年 12 月 4 日
R=B(cell2mat(A(:,2)))

その他の回答 (0 件)

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by