How do I combine cells in cell array?
5 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Asheton Arnold
am 28 Mär. 2020
Kommentiert: Asheton Arnold
am 28 Mär. 2020
I am trying to combine each row to be just a single string. is there anything I could do?
table =
7×13 cell array
Columns 1 through 9
{'Why'd' } {'you' } {'have' } {'to' } {'go' } {'and' } {'make' } {'have' } {'so' }
{'I' } {'see' } {'the' } {'way' } {'you're' } {'acting' } {'like' } {'you're' } {'somebody'}
{'Life's' } {'like'} {'this,' } {'have' } {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double}
{'And' } {'you' } {'fall,' } {'and' } {'you' } {'crawl,' } {'and' } {'you' } {'break' }
{'have' } {'you' } {'take,' } {'what' } {'you' } {'get,' } {'and' } {'you' } {'turn' }
{'Honesty'} {'and' } {'promise'} {'me' } {'I'm' } {'never' } {'gonna' } {'find' } {'you' }
{'No,' } {'have'} {'no' } {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double}
Columns 10 through 13
{'complicated?'} {0×0 double} {0×0 double} {0×0 double }
{'else' } {'gets' } {'me' } {'frustrated'}
{0×0 double } {0×0 double} {0×0 double} {0×0 double }
{0×0 double } {0×0 double} {0×0 double} {0×0 double }
{'it' } {'into' } {0×0 double} {0×0 double }
{'fake' } {'it' } {0×0 double} {0×0 double }
{0×0 double } {0×0 double} {0×0 double} {0×0 double }
Akzeptierte Antwort
Tommy
am 28 Mär. 2020
Bearbeitet: Tommy
am 28 Mär. 2020
Try
table = table';
strjoin(table(~cellfun(@(s) isa(s,'double'), table)))
to deal with those {0x0 double} cells.
EDIT
Ah ok. There might be a better way, but see if this works:
res = cell(size(table,1),1);
for i = 1:size(table,1)
row = table(i,:);
res{i} = strjoin(row(~cellfun(@(s) isa(s,'double'), table(i,:))));
end
Great song by the way!
2 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Tables finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!