How to sort out negative and positive values of a vector?
조회 수: 10 (최근 30일)
이전 댓글 표시
if A= -3 -2 -1 0 1 2 3 i want to sort the negative values and positive values in a separate vector
댓글 수: 0
채택된 답변
madhan ravi
2018년 10월 10일
편집: madhan ravi
2018년 10월 10일
A=[ -3 -2 -1 0 1 2 3 ]
Negative_nos = sort(A(A<0))
Positive_nos = sort(A(A>=0))
Will do the trick
댓글 수: 2
madhan ravi
2018년 10월 10일
편집: madhan ravi
2018년 10월 10일
sort(A(1:2)) %first two
sort(A(end-2:end)) %last three
give a vote if you find it useful
추가 답변 (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!