Multiple lines in single cell

8 次查看(过去 30 天)
Haritha
Haritha 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 CenterFile Exchange 中查找有关 TDMS Format Files 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by