Sorting the variable by comparing
조회 수: 12 (최근 30일)
이전 댓글 표시
I have two variables
A=[1000 16000 10000 30000 2000]
B=[150 100 4000 5000 2000]
I want to sort Variable B according to A
The 1st minimum of A is 1000 it is in 1syt position and B is 100 so 100 must be in first position
The 2nd minimum of A is 2000 it is in 5th position and B is 150,so 150 must be placed in 5th position ,and so on pleas help
C=[100 4000 2000 5000 150]
댓글 수: 0
채택된 답변
Dishant Arora
2012년 9월 15일
[~ ~ k]=unique(A);
B=unique(B);
C=B(k);
댓글 수: 4
Dishant Arora
2012년 9월 15일
편집: Dishant Arora
2012년 9월 15일
doc unique.
and the reason you got the error lies in the link below:
have a look at the answer by jan there.
추가 답변 (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!