summing tied (duplicate) numbers in a series
1 次查看(过去 30 天)
显示 更早的评论
Greetings to all, I have a time series data e.g. [4 4 6 7 9 9 9 10 10 13 17 17 17] which is long. I need to identify tied values such that t1=3(three untied values (6, 7, 13)), t2=2 (two ties of extent two (4, 10)), t3=2 (two ties of extent three (9, 17)).
After performing this, I need to sum all the ties in the series using the following equation... ti[(ti-1)(2ti+5)] where ti denotes the magnitude of the tie.
Anyone with suggestion on how to go about this is welcome to help.
Thanks in advance.
Vincent
1 个评论
Sean de Wolski
2012-4-10
Could you provide the output you expect for the above matrix?
It looks like (histc()||unique)+accumarray() will have a blast with this.
回答(2 个)
Thomas
2012-4-10
this is a start:
a=[4 4 6 7 9 9 9 10 10 13 17 17 17];
b=unique(a); % this shows unique values
c=find(diff(a)~=0) % finds the differences in the values
d=[0 c length(a)]; % making new matrix to get the values
outputs=sortrows([b' diff(d)'],2)
% follow this by summing your ties..
0 个评论
Andrei Bobrov
2012-4-10
t = [4 4 6 7 9 9 9 10 10 13 17 17 17]
[a n n] = unique(t)
m = histc(n,1:max(n))
tout = accumarray(m',a',[],@(x){x})
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Multirate Signal Processing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!