How do I combine cells in cell array?

1 回表示 (過去 30 日間)
Asheton Arnold
Asheton Arnold 2020 年 3 月 28 日
コメント済み: Asheton Arnold 2020 年 3 月 28 日
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 }
  1 件のコメント
Asheton Arnold
Asheton Arnold 2020 年 3 月 28 日
I need to do this without hardcoding.

サインインしてコメントする。

採用された回答

Tommy
Tommy 2020 年 3 月 28 日
編集済み: Tommy 2020 年 3 月 28 日
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 件のコメント
Asheton Arnold
Asheton Arnold 2020 年 3 月 28 日
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 2020 年 3 月 28 日
Thank you so much!!!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeTables についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by