How do I combine cells in cell array?

2 visualizzazioni (ultimi 30 giorni)
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 }

Risposta accettata

Tommy
Tommy il 28 Mar 2020
Modificato: Tommy il 28 Mar 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 Commenti
Asheton Arnold
Asheton Arnold il 28 Mar 2020
that is close, but i need each row on its own line so i can put each line on its own line in a .txt
Asheton Arnold
Asheton Arnold il 28 Mar 2020
Thank you so much!!!

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Tables in Help Center e File Exchange

Prodotti

Community Treasure Hunt

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

Start Hunting!

Translated by