请帮我排好队

1次观看(过去30天)
Triveni
Triveni 2016年8月8日
评论道: Triveni 2016年8月8日
我有一行,
X = [0 0 0 0 0 0 40 40 -40 -40 -40 -40 -40 -40 80 80 80 80 80 80 80 80 80];x1 = x;
[xi, u_x] = hist(x1, unique(x1));
输出,
u_x =
-40 0 40 80
西
ξ=
6 5 2 6
但是我想根据给定的x来排序,
[0 40 -40 80]
而且
[5 2 6 6]
应该分别是x_u和x_i的输出。请帮帮我。

接受的答案

Stephen23
Stephen23 2016年8月8日
编辑:Stephen23 2016年8月8日
x =[0, 0, 0, 0, 0, 40岁,40岁,-40年,-40年,-40年,-40年,-40年,-40年,80年,80年,80年,80年,80年,80年);
[uni,idu] = unique(x);
[cnt,idx] = hist(x,uni);
[~,id] = sort(idu);
CNT = CNT (ids)
Idx = Idx (ids)
输出:
问=
5 2 6 6
idx =
0 40 -40 80

更多答案(0)

标签

社区寻宝

在MATLAB Central中找到宝藏,并发现社区如何帮助您!

开始狩猎!