How do I have my variable output be uniform?

2 ビュー (過去 30 日間)
Steven D
Steven D 2022 年 4 月 23 日
コメント済み: Rik 2022 年 4 月 24 日
I would like the following output (as shown in the attached pic), to be either just horizontal (i.e., single column), or vertical (i.e., two columns) for each series of vertex coordinates. Right now, each series larger than 5 pairs of coordinates is listed as a double (or two column output), as shown in the pic with red arrows. Conversely, each series smaller than 6 pairs of coordinates is listed in a single, horizontal cell. Could someone let me know how to change the code (and/or Matlab preferences) such that the output would be uniform? Thanks in advance for any help you could offer.
Relevent Section of Code:
% for each internal cell, obtain vertex coordinates.
for i=1:size(vrInf,1)
for j=3:length(vrInf{i})
% find position of vertex coordinates in boundary pixel lists.
for i=1:size(faVrInf,1)
if any(intCell==i)==1
for j=1:size(faVrInf{i},1)
  5 件のコメント
Steven D
Steven D 2022 年 4 月 24 日
I was originally planning to write the data (stored in the variable) to an external file for use in excel; that's why I wanted the data to be fully displayed. Otherwise, some of the cells come through as text (e.g. "6x2 double"), Alternatively, I suppose I could just do all the comparing in Matlab.
Rik 2022 年 4 月 24 日
You can also write all the data to excel if you so choose, but even then, it doesn't matter how the data is displayed in Matlab, only how it stores it in your excel file.


回答 (2 件)

Rik 2022 年 4 月 23 日
Arrays in Matlab must be rectangular. The image you show does not show how the data is stored, it is merely a display. For longer arrays, the data is summarized with just the size and the type.
If you want to make each cell contain the same size array, you will have to either extend the smaller arrays, or remove elements from the larger arrays. Which of these you want is not clear to me from your question. Right now, all your data is in two-column matrices.

Walter Roberson
Walter Roberson 2022 年 4 月 23 日
編集済み: Walter Roberson 2022 年 4 月 23 日
You are using the variable browser. The variable browser does not provide any way to customize the output for Mathworks-provided datatypes -- other than choosing the default format specification for the times that it displays contents at all.
If you were defining your own object class, then you would be able to customize the display, with sufficiently new versions of MATLAB. See
To do what you want, you would have to design your own display routines instead of using the variable browser.
You could cellfun(@mat2str) your cell and display the results, but if I recall correctly that display will also eventually truncate and show you "..." instead of the rest of the output.
Historically the number of elements displayed in the command window depended on the width of the command window -- but it had to be somewhere around 2400 pixels wide before the first increase in number of elements occurred (I do not recall the exact boundary; wider than most people's displays though.) I have not checked to see if that is still the case. In the time since I last looked at that code, Mathworks increased the default number of values displayed in the command window. And command window is not the same as the variable browser anyhow.


Help Center および File ExchangeData Import from MATLAB についてさらに検索




Community Treasure Hunt

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

Start Hunting!

Translated by