How do I have my variable output be uniform?

1 visualizzazione (ultimi 30 giorni)
Steven D
Steven D il 23 Apr 2022
Commentato: Rik il 24 Apr 2022
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.
faVrInf=cell(size(bndPx,1),1);
for i=1:size(vrInf,1)
for j=3:length(vrInf{i})
faVrInf{vrInf{i}(j)}(end+1,:)=[vrInf{i}(1),vrInf{i}(2)];
end
end
% find position of vertex coordinates in boundary pixel lists.
faVrPsInf=cell(size(faVrInf,1),1);
for i=1:size(faVrInf,1)
if any(intCell==i)==1
for j=1:size(faVrInf{i},1)
faVrPsInf{i}(j)=find(ismember(bndPxSrt{i},faVrInf{i}(j,:),...
'rows'),1);
end
faVrPsInf{i}=sort(faVrPsInf{i});
end
end
  5 Commenti
Steven D
Steven D il 24 Apr 2022
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
Rik il 24 Apr 2022
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.

Accedi per commentare.

Risposte (2)

Rik
Rik il 23 Apr 2022
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 il 23 Apr 2022
Modificato: Walter Roberson il 23 Apr 2022
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 https://www.mathworks.com/help/matlab/group_analysisopt.html
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.

Prodotti


Release

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by