replacing ascending numbers with continous numbers
조회 수: 2 (최근 30일)
이전 댓글 표시
Hello everybody,
I am looking for a fast and efficient way to convert a vector of non continous ascending numbers to continous numbers.
As an example:
The vector
[4 20 35 22 10 49]
should become
[1 3 5 4 2 6]
at the moment I'm using a for loop, look for the lowest number write the runtime index into the result vector and set the position in the original vector to an illegal value. I know this is not the best way but it was the only one I could think of.
Also I'm not doing a single vector at a time but doing this to the columns of a matrix.
Thank you
댓글 수: 0
채택된 답변
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Matrix Indexing에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!