필터 지우기
필터 지우기

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 CenterFile Exchange에서 Data Types에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by