2%> Display the components of an input MATLAB variable on MATLAB Console recursively.
5%> This function is particularly useful
for displaying the
6%> hierarchical contents of a MATLAB ``
struct`` or ``cell``
object.
8%> \param[in] obj : The input variable whose contents are to be displayed on MATLAB Console.
10%> <li> If the input ``obj`` is a MATLAB ``
struct``, the function will
11%> recursively
show the ``obj``
name, its fieldnames, and their contents.
12%> <li> If the input ``obj`` is a cell array, the contents of each cell are displayed.
14%> (**optional**.
default = ``[]``, effectively adding a
new line to the command line.)
15%> \param[in]
name : The input scalar MATLAB string, representing the actual
name of the input ``obj``.<br>
16%> (**optional**. If missing, the ``obj`` variable
name from the caller workspace is used.)
17%> \param[in] hidden : The input scalar MATLAB ``logical``.<br>
18%> If ``
true``, then the contents of the input ``
struct`` will not be shown, only the field names.<br>
19%> (**optional**,
default = ``
false``)
26%> pm.matlab.show(obj);
27%> pm.matlab.show(obj,
name);
28%> pm.matlab.show(obj, [], hidden);
29%> pm.matlab.show(obj,
name, hidden);
34%> \include{lineno} example/matlab/
show/main.m
36%> \include{lineno} example/matlab/
show/main.out.m
41%> \FatemehBagheri, May 20 2024, 1:25 PM, NASA Goddard Space Flight Center (GSFC), Washington, D.C.<br>
42%> \AmirShahmoradi, May 16 2016, 9:03 AM, Oden Institute
for Computational Engineering and Sciences (ICES), UT Austin<br>
66 %%%% The number of elements to be displayed.
72 hmax = min(1, objsize);
75 %%%% Recursively display structure including fieldnames.
78 fnames = fieldnames(obj(h));
79 fnamesCount = length(fnames);
80 for i = 1 : fnamesCount
84 namei = [
name '(' ind2str(siz, h)
').' fnames{i}];
86 namei = [
name '(' ind2str(siz, objsize)
').' fnames{i}];
89 namei = [
name '.' fnames{i}];
91 if isstruct(obj(h).(fnames{i}))
92 pm.matlab.show(obj(h).(fnames{i}), namei, hidden);
94 if iscell(obj(h).(fnames{i}))
95 siz = size(obj(h).(fnames{i}));
96 NC = numel(obj(h).(fnames{i}));
104 Namej = [namei
'{' ind2str(siz,j)
'}'];
106 Namej = [namei
'{' ind2str(siz,NC)
'}'];
110 disp(obj(h).(fnames{i}){j});
116 disp(obj(h).(fnames{i}));
125 %%%% Recursively display cell.
128 for i = 1 : numel(obj)
129 namei = [
name '{' ind2str(siz,i)
'}'];
130 pm.matlab.show(obj{i}, namei, hidden);
146function str = ind2str(siz, ndx)
147 %%%% Treat vectors and scalars correctly.
158 k = [1 cumprod(siz(1 : end - 1))];
162 v = floor(ndx / k(i)) + 1;
166 str = [num2str(v)
',' str];
168 ndx = rem(ndx, k(i));
function name(in vendor)
Return the MPI library name as used in naming the ParaMonte MATLAB shared library directories.
function show(in obj, in name, in hidden)
Display the components of an input MATLAB variable on MATLAB Console recursively.