Is there a command ( like "sort" for example ) arranges vector elements ascending ,max, descending (humped shap)?
조회 수: 1 (최근 30일)
이전 댓글 표시
Is there a command ( like "sort" for example ) arranges vector elements ascending ,max, descending (humped shap)?
댓글 수: 6
채택된 답변
Stephen23
2019년 10월 28일
>> V = randi(99,1,23)
V =
93 68 76 74 39 65 17 70 4 28 5 10 82 69 32 95 4 44 38 76 79 19 49
>> Y = sort(V);
>> Z = [Y(1:2:end),fliplr(Y(2:2:end))]
Z =
4 5 17 28 38 44 65 69 74 76 82 95 93 79 76 70 68 49 39 32 19 10 4
추가 답변 (1개)
Yuan Li
2019년 10월 28일
Yes. Use sort.
e.g.
a = [1,3,2,4];
b = sort(a,'ascend');% b = [1,2,3,4]
c = sort(a,'descend');% c = [4,3,2,1]
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!