Change how cells are printed
Show older comments
I just downloaded MATLAB R2018b, and every time I want to view the contens of a cell in the command window, every cell entry is printed inside curly brackets. If a column of the cell contains numbers, the numbers are printed within square brackets, which are again within curly brackets. This is a bit annoying, and it used to look different in my previous MATLAB version. Is there any way to stop MATLAB from printing all cell entries within curly brackets, without using a function? I want to change how the cells are printed when I just call them without using a function. I also have several custom written functions where the output is a cell, and I have the same problem here. Also, every time I print a cell, MATLAB obviously feels the need to tell me that it is a cell structure, and also the dimension of it. I would also like to turn that off. Anyone knows how? I have checked the preferences, and I cannot see anything there.
Answers (1)
Star Strider
on 3 Jan 2019
Cell array indexing can be a bit confusing when you first encounter it.
One possible approach:
C = {{rand(1,10)}, {rand(8,2)}};
V1 = [C{1}{:}]
V2 = [C{2}{:}]
Remember, cell arrays can contain anything, not only numerical cata, so you may need to use the cellfun (link) function, for example, to work with them.
See the documentation sections on Cell Arrays (link), and Access Data in Cell Array (link) for extended discussions.
3 Comments
Gunvor Røkke
on 3 Jan 2019
Star Strider
on 3 Jan 2019
My pleasure.
I doubt that changing the output format for cells, structures, and other data types can be controlled by users. I would use the Contact Us link at the top right corner of this page to ask MathWorks directly.
Include the URL of this thread in your note to them so you don’t have to repeat all of it.
Walter Roberson
on 4 Jan 2019
There is some small customization available by adding parameters to disp() but removing the extra braces is not provided for .
Categories
Find more on Matrix Indexing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!