How do I combine cells in cell array?
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Asheton Arnold
el 28 de Mzo. de 2020
Comentada: Asheton Arnold
el 28 de Mzo. de 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 }
Respuesta aceptada
Tommy
el 28 de Mzo. de 2020
Editada: Tommy
el 28 de Mzo. de 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 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Tables en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!