Effacer les filtres
Effacer les filtres

Sort and Arrange Matrix for Lookup Table - monotonically increasing

3 vues (au cours des 30 derniers jours)
Marv
Marv le 24 Juil 2015
Modifié(e) : Marv le 27 Juil 2015
Hi, I want to prepare my data for a lookup table. It must be monotonically increasing: How can I do that ?
For example:
Before:
NAN 6 1 8 3 12 10 9
8 Q O R P U T S
1 C A D B G F E
4 J H K I N M L
13 L J M K P O N
9 X V Y W B A Z
12 E C F D I H G
After:
NAN 1 3 6 8 9 10 12
1 A B C D E F G
4 H I J K L M N
8 O P Q R S T U
9 V W X Y Z A B
12 C D E F G H I
13 J K L M N O P

Réponse acceptée

Walter Roberson
Walter Roberson le 24 Juil 2015
After = sortrows(sortrows(Before).').';
  4 commentaires
Guillaume
Guillaume le 27 Juil 2015
@Marv, Walter's answer does exactly as you want (assuming your data is just a matrix of numbers, unlike your example). It first sorts the rows by the first column, then the columns by the first rows. NaN does not have an ordering, so sortrows puts it at the end.
If you want the NaN row/column to come first, simply replace the NaN by -Inf.
Marv
Marv le 27 Juil 2015
Modifié(e) : Marv le 27 Juil 2015
Great ! Thank you very much, it works :)
How can I export these sorted values for the Lookup Table ?
For example:
Table Data = Value_Matrix11,...,Value_MatrixRow1N;Value_Matrix21,...,Value_MatrixRow2N]
Breakpoint1 = [Value_Matrix1,...,Value_MatrixN]
I look for ouputted the values in correct format, so that I just have to copy paste it in the lookup table editor :)

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Matrices and Arrays 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