Merging cells,adding contents

7 visualizaciones (últimos 30 días)
Andreas
Andreas el 17 de Nov. de 2013
Comentada: Andreas el 17 de Nov. de 2013
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..

Respuesta aceptada

Azzi Abdelmalek
Azzi Abdelmalek el 17 de Nov. de 2013
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)]
  1 comentario
Andreas
Andreas el 17 de Nov. de 2013
aaaaamazing. thank you Azzi for your precise and quick answer.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Geometric Transformation and Image Registration en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by