Sorting a cell array (text) in the order of a colperm solution

조회 수: 1 (최근 30일)
Moritz Geiger
Moritz Geiger 2017년 7월 27일
답변: Moritz Geiger 2017년 7월 29일
Hello Community! I have a 21x1 cell array containing text in the format 'XYZ'. Its name is nNames. I also have a 1x21 double array from the solution of colperm(). Its name is sortB.
Now I would like to bring the Text array in the order of the colperm order. I tried without success:
namessort=sort(nNames,sortB)
Is there any possibility to do this sorting or at least to print a List or Table where I can bring the text and the order together. Possibly very stupid, but this table could be processed in EXCEL - sorry for this.
Do you have a suggestion?

채택된 답변

alice
alice 2017년 7월 27일
namessort=nNames(sortB);
Does this gives what you want? If not, sorry but I haven't understood what you want to do.
To display a table with the text of your cell and the order provided by sortB:
sortB = sortB';
myTable = table(nNames,sortB)

추가 답변 (1개)

Moritz Geiger
Moritz Geiger 2017년 7월 29일
Thank you! It works. It must be:
myTable = table(namessort,sortB)
Then everything is like I wanted it to be!
Thank you!

카테고리

Help CenterFile Exchange에서 Characters and Strings에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by