Merge rows of cell array with strings per column?
5 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Jonathan
am 4 Okt. 2022
Kommentiert: Jonathan
am 4 Okt. 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 Kommentare
Akzeptierte Antwort
Stephen23
am 4 Okt. 2022
C = {'A','C'; 'B','D'}
D = cellfun(@(c)join(c,''),num2cell(C,1))
D = cellfun(@(c)[c{:}],num2cell(C,1),'uni',0)
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Characters and Strings finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!