フィルターのクリア

unique the string but sum the values

1 回表示 (過去 30 日間)
Shayma
Shayma 2015 年 2 月 4 日
コメント済み: Shayma 2015 年 2 月 5 日
Hi everyone;
i have a cell array:which has name in the first column and value in the second one, i want to create a new array which will have the "unique" name but the sum of the values in the second column for each one, how can i do that? [C,ia,ic] = unique(new(:,1)) >> can use the ia and ic to refer to? how
any ideas?
new= 'a_nBr' [155] 'BCUT_PEOE_0' [302] 'BCUT_PEOE_3' [ 25] 'BCUT_SLOGP_3' [160] 'BCUT_SMR_1' [ 39] 'b_double' [286] 'b_triple' [131] 'GCUT_PEOE_3' [282] 'GCUT_SLOGP_1' [320] 'opr_brigid' [ 14] 'PEOE_VSA+6' [ 60] 'PEOE_VSA-2' [ 81] 'PEOE_VSA-5' [144] 'Q_VSA_FPPOS' [292] 'reactive' [ 95] 'SlogP_VSA2' [150] 'SMR_VSA2' [173] 'SMR_VSA3' [ 49] 'vsa_other' [107] 'a_acid' [136] 'a_nBr' [134] 'balabanJ' [ 21] 'BCUT_PEOE_0' [339] 'BCUT_PEOE_3' [ 3] 'BCUT_SLOGP_1' [ 14] 'BCUT_SLOGP_3' [158] 'b_double' [294] 'b_triple' [180] 'GCUT_PEOE_3' [295] 'GCUT_SLOGP_1' [241] 'mutagenic' [124] 'opr_brigid' [ 20] 'PEOE_VSA-2' [ 82] 'PEOE_VSA-5' [218] 'Q_VSA_FPPOS' [326] 'reactive' [ 73] 'SlogP_VSA2' [113]

採用された回答

Azzi Abdelmalek
Azzi Abdelmalek 2015 年 2 月 4 日
str={'a_nBr' [155]
'BCUT_PEOE_0' [302]
'BCUT_PEOE_3' [ 25]
'BCUT_SLOGP_3' [160]
'BCUT_SMR_1' [ 39]
'b_double' [286]
'b_triple' [131]
'GCUT_PEOE_3' [282]
'GCUT_SLOGP_1' [320]
'opr_brigid' [ 14]
'PEOE_VSA+6' [ 60]
'PEOE_VSA-2' [ 81]
'PEOE_VSA-5' [144]
'Q_VSA_FPPOS' [292]
'reactive' [ 95]
'SlogP_VSA2' [150]
'SMR_VSA2' [173]
'SMR_VSA3' [ 49]
'vsa_other' [107]
'a_acid' [136]
'a_nBr' [134]
'balabanJ' [ 21]
'BCUT_PEOE_0' [339]
'BCUT_PEOE_3' [ 3]
'BCUT_SLOGP_1' [ 14]
'BCUT_SLOGP_3' [158]
'b_double' [294]
'b_triple' [180]
'GCUT_PEOE_3' [295]
'GCUT_SLOGP_1' [241]
'mutagenic' [124]
'opr_brigid' [ 20]
'PEOE_VSA-2' [ 82]
'PEOE_VSA-5' [218]
'Q_VSA_FPPOS' [326]
'reactive' [ 73]
'SlogP_VSA2' [113]}
[ii,jj,kk]=unique(str(:,1))
out=[ii num2cell(accumarray(kk,[str{:,2}]'))]
  1 件のコメント
Shayma
Shayma 2015 年 2 月 5 日
Thank you very much :)

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeRead Data from Channel についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by