Sort a string array according to equivalent names of another string array
조회 수: 11 (최근 30일)
이전 댓글 표시
I'm trying to sort string array "S1" according to the order of the equivalent string names in the string array "names". New to Matlab so I would tend towards comparing and looping, but hoping there's a more efficient method someone may know using the sort function.

댓글 수: 0
채택된 답변
Fangjun Jiang
2022년 11월 10일
이동: Fangjun Jiang
2022년 11월 10일
names=["A";"B";"C";"D";"E"];
S1=["d";"c";"e";"a";"b"];
[~,index]=ismember(names, upper(S1));
S2=S1(index)
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Shifting and Sorting Matrices에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!