¿How to order 'x' numbers in ascending or descending?
3 views (last 30 days)
Show older comments
I did this for two numbers, but I find it difficult for an indefinite amount of numbers (as input vector).
I was thinking of a nested loop.
I have come to this point:
V=input('Ingrese el vector V= ');
Alessandro Masullo on 9 Oct 2012
If you don't want to use sort (may be for practicing?), here is a simple alternative:
a = round(rand(1, 10)*20)
tmp = a;
t = zeros(1, length(a));
for i = 1:length(a)
m = find(tmp == min(tmp));
t(i) = tmp(m(1));
tmp(m(1)) = ;
More Answers (1)
Julien on 9 Oct 2012
Hi, this function already exists on Matlab. It is called 'sort'
Additional information here
Find more on Resizing and Reshaping Matrices in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!