MATLAB Answers

How to reorder cell array based on the vector

3 views (last 30 days)
Na
Na on 24 Mar 2020
Answered: Sindar on 24 Mar 2020
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]};

  0 Comments

Sign in to comment.

Accepted Answer

Sindar
Sindar on 24 Mar 2020
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 Comments

Sign in to comment.

More Answers (0)

Sign in to answer this question.