Merging cells,adding contents
7 次查看(过去 30 天)
显示 更早的评论
Hey everyone.! I have some data in this form
'Mary' [ 37]
'Lisa' [ 18]
'George' [ 20]
'Nick' [ 49]
'Mary' [ 24]
'George' [ 4]
'Lisa' [ 36]
(random names with random sequence)and I want to have this
'Mary' [ 61]
'Lisa' [ 54]
'George' [ 24]
'Nick' [ 49]
(not necessarily in this order) Any good ideas? Thank you all..
0 个评论
采纳的回答
Azzi Abdelmalek
2013-11-17
v={'Mary' [ 37]
'Lisa' [ 18]
'George' [ 20]
'Nick' [ 49]
'Mary' [ 24]
'George' [ 4]
'Lisa' [ 36]}
[a,b,c]=unique(v(:,1),'stable')
n=accumarray(c,[v{:,2}]')
out=[a num2cell(n)]
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!