[X_sort, X_ind] = sort(X, num, direction)
Input)
X
: 벡터 혹은 행렬 데이터
num = 1 or 2 (default = 1)
: X가 행렬일 때 1이면 열을 기준으로, 2면 행을 기준으로 정렬한다.
direction = 'ascend' or 'descend' (default = 'ascend')
: 정렬 기준을 정한다. ascend는 오름차순, descend는 내림차순이다.
Output)
X_sort
: 정렬한 X의 값이다.
X_ind
: 정렬한 X의 순서를 의미한다.
X가 벡터일 경우 다음은 참이다.
X_sort == X(X_ind)
X가 행렬이고 num = 1이면 j열에 대하여 다음은 참이다.
X_sort(:,j) == X(X_ind(:,j),j)
X가 행렬이고 num = 2이면 i행에 대하여 다음은 참이다.
X_sort(i,:) == X(i,X_ind(i,:))
Reference)
https://kr.mathworks.com/help/matlab/ref/sort.html
'Programming > Matlab' 카테고리의 다른 글
Block Tridiagonal Matrix 만들기 (0) | 2017.03.05 |
---|---|
OS X용 MATLAB에서 MEX C Compiler 변경하기 (0) | 2017.02.26 |
Introduction to Numerical Methods and Matlab Programming for Engineers (0) | 2017.01.20 |