function s = boxscope(v,vert) % s = boxscope(v,vert): return picture $s$ of value $v$ % in a vertical/horizontal ($vert$ is true/false, resp.) format; % objects are not supported; datatypes are mostly not explicitly shown if nargin<=1 vert = 0; end if isobject(v) warning('dunno how to display objects'); s = ''; return; end if ischar(v) s(1:(3+length(v)+3)) = '-'; s([1 end]) = '+'; m = size(v,1); s = [s ; repmat('| ''', m,1) v repmat(''' |', m,1) ; s ]; return; end if isempty(v) s = ['+----+' ; '| |' ; '+----+' ]; return; end [m,n] = size(v); for j = 1:n if isnumeric(v) tmp = num2str(v(:,j)); % right justify numbers in a column end for i = 1:m if iscell(v) t{i,j} = boxscope(v{i,j},vert); elseif isstruct(v) t{i,j} = boxstruct(v(i,j),vert); elseif isnumeric(v) t{i,j} = tmp(i,:); else error('dunno even what kind of value it is') end [mm(i,j),nn(i,j)] = size(t{i,j}); end end mm = max(mm,[],2); mm = cumsum(1+[0 ; mm]); nn = max(nn,[],1); nn = cumsum(1+[0 nn]); s(1:mm(end), 1:nn(end)) = ' '; s(mm,1:nn(end)) = '-'; s(1:mm(end), nn) = '|'; s(mm, nn) = '+'; for i = 1:m for j = 1:n tmp = t{i,j}; [mi,nj] = size(tmp); s(mm(i)+(1:mi), nn(j)+(1:nj)) = tmp; end end function s = boxstruct(v,vert) % s = boxstruct(v,vert): return picture $s$ of 1-by-1 struct array $v$ % in a vertical/horizontal ($vert$ is true/false, resp.) format; % fields with names ending in $_$ are displayed without the fieldname % and without a box around the value fields = fieldnames(v); s = []; for k = 1:length(fields) f = fields{k}; fv = boxscope(getfield(v,f)); % fix things up if field names ends in $_$ if f(end) ~= '_' f = [f ' ']; else f = ''; % omit fieldname % delete surrounding box fv([1 end],:) = []; fv(:,[1 end]) = []; % delete surrounding spaces and/or quotes if all(fv(:,1) == ' '), fv(:,1) = []; end if all(fv(:,end) == ' '), fv(:,end) = []; end if all(fv(:,[1 end]) == ''''), fv(:,[1 end]) = []; end end % build up picture $s$ -- vertically or horizontally, as requested if vert f = strvcat(f, fv); s = strhcat(s, f, ' '); else f = strhcat(strvcat(' ',[' ' f]), fv); s = strvcat(s, strhcat(f, ' ')); end end