How to sort out negative and positive values of a vector?
10 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Shubham Mohan Tatpalliwar
am 10 Okt. 2018
Bearbeitet: madhan ravi
am 10 Okt. 2018
if A= -3 -2 -1 0 1 2 3 i want to sort the negative values and positive values in a separate vector
0 Kommentare
Akzeptierte Antwort
madhan ravi
am 10 Okt. 2018
Bearbeitet: madhan ravi
am 10 Okt. 2018
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 Kommentare
madhan ravi
am 10 Okt. 2018
Bearbeitet: madhan ravi
am 10 Okt. 2018
sort(A(1:2)) %first two
sort(A(end-2:end)) %last three
give a vote if you find it useful
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Shifting and Sorting Matrices finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!