How to reorder cell array based on the vector

조회 수: 51 (최근 30일)
NA
NA 2020년 3월 24일
답변: Sindar 2020년 3월 24일
I have
index = [1; 2; 4; 3; 7; 6; 5];
list = {[1158;1159], [1543;1544], [2020;2096;2173], [2159], [4836], [5374], [5492;5493]};
list_sort = cellfun(@(x) x(index') ,list,'UniformOutput',false );
List_sort should be
list_sort = {[1158;1159], [1543;1544], [2159], [2020;2096;2173], [5492;5493], [5374], [4836]};

채택된 답변

Sindar
Sindar 2020년 3월 24일
index = [1; 2; 4; 3; 7; 6; 5];
list = {[1158;1159], [1543;1544], [2020;2096;2173], [2159], [4836], [5374], [5492;5493]};
list_sort = list(index);

추가 답변 (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