Multiple lines in single cell

25 ビュー (過去 30 日間)
Haritha
Haritha 2019 年 5 月 8 日
回答済み: Bob Thompson 2019 年 5 月 8 日
Hi I have a cell array as trob = 2*1 cell with sub cells as 4*1 and 5*1
trob={{'1.Check number'
'2.Should the issue be consistent'
'3.Understand the issue'
'4.Check compatibility '};
{'1.Check version '
'2.Check issue '
'3.Check on different connectors.'
'4.Run diagnostic).'
'5.Send defect'}}
I neead to create as trob = 2*1 cell and sub cells as 1*1 insead of 4*1 ad 1*1 instead of 5*1. Is it possible to do that. I tried with '\n'... also its not working for me.Please help me if anyone knows

回答 (1 件)

Bob Thompson
Bob Thompson 2019 年 5 月 8 日
If I am understanding you correctly, you want to use to combine your strings into a single string, but maintain the individual rows. I would suggest using join.
for i = 1:length(trob)
trob(i) = join(trob(i),'\n')
end
The results of this is two cell arrays with all sentances strung together with \n delimiters. It is not pretty to look at in the workspace, but if you print it with fprintf you receive the format you're looking for.
>> fprintf(trob{1})
1.Check number
2.Should the issue be consistent
3.Understand the issue
4.Check compatibility >> % The next line starts here because we haven't put a \n on the end of the last line

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by