Merge rows of cell array with strings per column?
4 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Jonathan
el 4 de Oct. de 2022
Comentada: Jonathan
el 4 de Oct. de 2022
I have a cell array of 2xn with strings and I would like to merge the text of all rows on a per column base, effectively yielding a 1xn cell array. To illustrate I have something like this...
[{'A'} {'C'}; {'B'} {'D'}]
... and would like something like this:
[{'AB'} {'CD'}]
0 comentarios
Respuesta aceptada
Stephen23
el 4 de Oct. de 2022
C = {'A','C'; 'B','D'}
D = cellfun(@(c)join(c,''),num2cell(C,1))
D = cellfun(@(c)[c{:}],num2cell(C,1),'uni',0)
Más respuestas (0)
Ver también
Categorías
Más información sobre Characters and Strings 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!