フィルターのクリア

summing tied (duplicate) numbers in a series

1 回表示 (過去 30 日間)
Vincent Odongo
Vincent Odongo 2012 年 4 月 8 日
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
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
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..

Andrei Bobrov
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})

カテゴリ

Help Center および File ExchangeMathematics についてさらに検索

タグ

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by