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!