summing tied (duplicate) numbers in a series
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaire
Sean de Wolski
le 10 Avr 2012
Could you provide the output you expect for the above matrix?
It looks like (histc()||unique)+accumarray() will have a blast with this.
Réponses (2)
Thomas
le 10 Avr 2012
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 commentaires
Andrei Bobrov
le 10 Avr 2012
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 commentaires
Voir également
Catégories
En savoir plus sur Multirate Signal Processing 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!