unique the string but sum the values
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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]
0 commentaires
Réponse acceptée
Azzi Abdelmalek
le 4 Fév 2015
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}]'))]
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Read Data from Channel 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!