Sort a vector in matlab
이전 댓글 표시
Somebody can help me? From the routine in Matlab I get a vector whose length can be a number between 0 and 24. The content of this vector are numbers between 0 and 24. However, I have to sort this vector with the next conditions
1. The content must be equal to index of the sorted vector. 2. If in the content of the vector, a number doesn't exist must be equal to NaN
For example
Index Content
- 1 10
- 2 11
- 3 12
- 4 15
- 5 16
- 6 17
- 7 18
- 8 19
- 9 20
- 10 22
- 11 24
In the left side is index vector and in right side the content The sorted vector that I hope to get is:
- 1 2
- 2 2
- 3 3
- 4 4
- 5 5
- 6 6
- 7 7
- 8 8
- 9 9
- 10 10
- 11 11
- 12 12
- 13 13
- 14 14
- 15 15
- 16 16
- 17 17
- 18 18
- 19 19
- 20 20
- 21 21
- 22 22
- 23 23
- 24 24
Thank for your help!
댓글 수: 2
the cyclist
2015년 8월 27일
편집: the cyclist
2015년 8월 27일
I don't understand the rule you are trying to explain, or your example. Can you use actual MATLAB commands to define your input/output, such as
x = [1 10; 2 11; etc]
y = [1 2; 2 2; 3 3; etc]
and give another example or two of input/output?
Camilo Corredor
2015년 8월 27일
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 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!