sorting specific columns of a matrix
Mostrar comentarios más antiguos
trying not to sort entire matrix just the columns that conforms the rule. the example is a =[8 6 7; 9 6 7; 10 7 8; 9 9 8; 10 9 8; 9 9 10; 10 9 10; 11 9 10]; I want to sort the rows according to 2 and 3 respectively, but if the value on the second row is greater than the value on the third row this columns should also be sorted by the first column descending. The answer should be: b = [8 6 7; 9 6 7; 10 7 8; 10 9 8; 9 9 8; 9 9 10; 10 9 10; 11 9 10]; any advice?
Respuestas (1)
out = sort(a, 'descend');
for ascending order
sort(a, 'ascend');
6 comentarios
Ozgur Avsar
el 24 de En. de 2016
Triveni
el 24 de En. de 2016
what's problem??
Ozgur Avsar
el 24 de En. de 2016
Triveni
el 24 de En. de 2016
what answer exactly you want???
Ozgur Avsar
el 24 de En. de 2016
Ozgur Avsar
el 24 de En. de 2016
Categorías
Más información sobre Shifting and Sorting Matrices en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!