![]() |
我需要订购依赖于另一个列表的列表。如何更改两个列表?
我有一个Matlab程序,该程序生成一个列表x = 6.1692 8.1863 5.8092 8.2754 6.0891该程序还输出另一个列表aspl = 680637669669599693。
这两个列表的长度相等,并且列表x中的第一个元素与列表aspl中的第一个元素相关。我需要绘制两个列表的图,但希望列表aspl从最小到最大依次排列。我将如何去做呢?如果我需要将aspl中的第一个元素移动到列表中的位置4,那么列表x中的第一个元素也需要移动到列表x中的位置4。上面的数字并不重要,它们只是示例,实际程序会产生混乱的数字。 例如x = 6.1692 8.1863 5.8092 8.2754最初 aspl = 680 637 669 599 693 将aspl更改为升序后,这就是x的外观。 x = 5.8092 8.1863 5.8092 6.1692 8.2754 aspl = 599637669680693 [B]回答:[/B] 使用排序的第二个输出: %# sort aspl, get new order of aspl [sortedAspl, sortOrder] = sort(aspl); %# reorder x the same way as aspl sortedX = x(sortOrder); [url=https://stackoverflow.com/questions/2512864]更多&回答...[/url] |
所有时间均为北京时间。现在的时间是 04:52。 |
Powered by vBulletin
版权所有 ©2000 - 2025,Jelsoft Enterprises Ltd.