change the order of a row vecor

조회 수: 2 (최근 30일)
lowcalorie
lowcalorie 2012년 2월 5일
Hello I have a vector [ -90 -54 -12 -2]
I need to make the vector elements go from least negative to most negative to look like [-2 -12 -54 -90] and i need the program to work for any size row vector I am using I am having trouble getting this to work any help??

채택된 답변

Junaid
Junaid 2012년 2월 5일
Hi,
let say your row vector is:
a=[-90 -54 -12 -2];
b = sort(a,2,'descend');
vector b contains your desired output. It works for any size row vector.

추가 답변 (1개)

lowcalorie
lowcalorie 2012년 2월 5일
awesome thanks a lot

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by