Matlab:以升序对行进行排序,但跟踪原始索引 [英] Matlab: Sorting rows in ascending order but tracking original index

查看:172
本文介绍了Matlab:以升序对行进行排序,但跟踪原始索引的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个大小为50 x 10的数组"A",其中包含双打.

I have an array 'A' of size 50 x 10 filled with doubles.

我想按升序排列每一行以获得新的数组'B',但我想创建第三个数组'C',在其中跟踪原始数组'A'的索引

I want to arrange each row in ascending order to get a new array 'B' but I want to create a third array 'C' where I keep track of the index from original array 'A'

例如

数组A(原始数组):

11   9   13   10
12   4   1    6  
13   5   12   12 

数组B(重新排列的数组):

Array B (rearranged array):

9   10   11   13
1   4    6    12
5   12   12   13

数组C(数组A的跟踪索引):

Array C (tracking index from array A):

2   4    1    3
3   2    4    1
2   3    4    1    

谢谢

推荐答案

您是否尝试过排序:

[b, c] = sort(A,2)

这篇关于Matlab:以升序对行进行排序,但跟踪原始索引的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆