필터 지우기
필터 지우기

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}]'))]

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Read Data from Channel에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by