Change how cells are printed

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)

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}{:}]
Using the cell2mat (link) function is another.
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

Thanks, but what I want to change is how the cells are displayed when I don't use a function to display them, when I just call a cell structure in the command window.
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.
There is some small customization available by adding parameters to disp() but removing the extra braces is not provided for .

Sign in to comment.

Asked:

on 3 Jan 2019

Commented:

on 4 Jan 2019

Community Treasure Hunt

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

Start Hunting!