Multiple lines in single cell

조회 수: 8 (최근 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 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