change the order of a row vecor

8 vues (au cours des 30 derniers jours)
lowcalorie
lowcalorie le 5 Fév 2012
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??

Réponse acceptée

Junaid
Junaid le 5 Fév 2012
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.

Plus de réponses (1)

lowcalorie
lowcalorie le 5 Fév 2012
awesome thanks a lot

Catégories

En savoir plus sur Simulink dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by