Combine two cell arrays containing string values into one.
10 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Marc Jakobi
el 25 de Sept. de 2013
Comentada: Johannes Rebling
el 7 de Abr. de 2020
Hi.
I have two cell arrays that look something like this:
A = {'1.'; '2.'; '3.'; '4.', '5.'};
B = {'A'; 'B'; 'C'; 'D'; 'E'};
Both are of the same length.
I want to combine them into a third cell array that looks like this:
C = {'1. A'; '2. B'; '3. C'; '4. D'; '5. E'};
How can I do this?
Thanks!
0 comentarios
Respuesta aceptada
Azzi Abdelmalek
el 25 de Sept. de 2013
Editada: Azzi Abdelmalek
el 25 de Sept. de 2013
A = {'1.'; '2.'; '3.'; '4.'; '5.'};
B = {'A'; 'B'; 'C'; 'D'; 'E'};
C=cellfun(@(x,y) [x ' ' y],A,B,'un',0)
3 comentarios
Johannes Rebling
el 7 de Abr. de 2020
For those like me, wondering what the 'un',0 at the end of cellfun means, it's the same as 'UniformOutput',true. Thanks for the solution!
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!