Line comment change string cell shape
显示 更早的评论
I found when I use line comment to erase some my content for a string cell, the cell shape change to row from original column
like this
>> a={'first' ...
, 'second' ...
, 'third'}
a =
'first' 'second' 'third'
>> a={'first' ...
% , 'second' ...
, 'third'}
a =
'first'
'third'
I have already tried 2013a and 2015b, they shared the same result.
I just want to change my test case sometime quickly for a simple test, but that messed up the following code with my for loop will use like this
for a_n = a
a_n = a_n{:};
That will be good if I don't comment anything, but failed to only loop once with my first case.
Any answer about why the shape of string cell will change when there are line comments is appreciated.
2 个评论
Bhaskar R
2019-12-20
I hope I understood your problem.
You have a cell matrix a
>> a={'first' ...
, 'second' ...
, 'third'}
a is a row matrix(shape is 1x3), if you comment any row/line of the a matrix, the shape of the matrix is converted to column matrix( that is 2x1 instread of 1x2), am I correct? if yes
you have used
...
in your matrix initialization that means continuous line that is equivalent to
a = {'first' , 'second','third'};
it is suggested you that remove "..." from the initialization so that you can preserve shape of the matrix a
JackXu
2019-12-20
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Characters and Strings 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!