1212% ncol: number of cols in grid
1313% ________________________________________________________________________________________
1414% VARARGIN
15- % | NAME | DEFAULT | DESCRIPTION
15+ % | NAME | DEFAULT | DESCRIPTION
1616% |-----------------|---------------|-----------------------------------------------------
17- % | parent | gcf | parent object for grid
18- % | relwidth | ones(1, ncol) | relative width of columns (arbitrary units)
19- % | relheight | ones(1, nrow) | relative height of rows (arbitrary units)
20- % | marginsep | 0.0100 | size of margin surrounding grid (normalized units)
21- % | panelsep | 0.0100 | size of space between panels (normalized units)
22- % | backgroundcolor | [.08 .09 .09] | uipanel background color
17+ % | parent | gcf | parent object for grid
18+ % | relwidth | ones(1, ncol) | relative width of columns (arbitrary units)
19+ % | relheight | ones(1, nrow) | relative height of rows (arbitrary units)
20+ % | marginsep | 0.0100 | size of margin surrounding grid (normalized units)
21+ % | panelsep | 0.0100 | size of space between panels (normalized units)
22+ % | backgroundcolor | [.08 .09 .09] | uipanel background color
2323% | foregroundcolor | [.97 .97 .97] | uipanel foreground color
24- % | bordertype | 'none' | etchedin, etchedout, beveledin, beveledout, line
24+ % | bordertype | 'none' | etchedin, etchedout, beveledin, beveledout, line
2525% | borderwidth | 1 | uipanel border width in pixels
2626% ________________________________________________________________________________________
2727%
5555if length(relwidth )~=ncol , printmsg(' Length of RELWIDTH must equal NCOL. Try again!' ); phandle = []; pidx = []; return ; end
5656if length(relheight )~=nrow , printmsg(' Length of RELHEIGHT must equal NROW. Try again!' ); phandle = []; pidx = []; return ; end
5757
58- % | Get normalized positions for each panel
58+ % | Get normalized positions for each panel
5959pos = getpositions(relwidth , relheight , marginsep , panelsep );
6060pidx = pos(: ,1 : 2 );
6161hpos = pos(: ,3 : end );
6262
6363% | pgrid loop
6464npanel = size(hpos , 1 );
65- phandle = gobjects(npanel , 1 );
65+ % phandle = gobjects(npanel, 1);
66+ phandle = zeros(npanel , 1 );
6667for i = 1 : npanel
67-
68+
6869 phandle(i ) = uipanel( ...
6970 ' Parent' , parent ,...
7071 ' Units' , ' normalized' ,...
9899if size(relheight ,1 ) > 1 , relheight = relheight ' ; end
99100if size(relwidth , 1 ) > 1 , relwidth = relwidth ' ; end
100101ncol = length(relwidth );
101- nrow = length(relheight );
102+ nrow = length(relheight );
102103if top2bottomidx , relheight = relheight(end : -1 : 1 ); end
103104
104105% width
105- rowwidth = 1 -(marginsep * 2 )-(uicontrolsep *(ncol - 1 ));
106+ rowwidth = 1 -(marginsep * 2 )-(uicontrolsep *(ncol - 1 ));
106107uiwidths = (relwidth / sum(relwidth ))*rowwidth ;
107108allsep = [marginsep repmat(uicontrolsep , 1 , ncol - 1 )];
108- uilefts = ([0 cumsum(uiwidths(1 : end - 1 ))]) + cumsum(allsep );
109+ uilefts = ([0 cumsum(uiwidths(1 : end - 1 ))]) + cumsum(allsep );
109110
110111% height
111112colheight = 1 -(marginsep * 2 )-(uicontrolsep *(nrow - 1 ));
119120pos = zeros(ncol * nrow , 6 );
120121pos(: ,1 ) = reshape(repmat(nrow : -1 : 1 , ncol , 1 ), size(pos ,1 ), 1 );
121122pos(: ,2 ) = reshape(repmat(1 : ncol , 1 , nrow ), size(pos ,1 ), 1 );
122- pos(: ,3 ) = uilefts(pos(: ,2 ));
123- pos(: ,4 ) = uibottoms(pos(: ,1 ));
124- pos(: ,5 ) = uiwidths(pos(: ,2 ));
123+ pos(: ,3 ) = uilefts(pos(: ,2 ));
124+ pos(: ,4 ) = uibottoms(pos(: ,1 ));
125+ pos(: ,5 ) = uiwidths(pos(: ,2 ));
125126pos(: ,6 ) = uiheights(pos(: ,1 ));
126127pos = sortrows(pos , 1 );
127128end
@@ -135,10 +136,10 @@ function mfile_showhelp(varargin)
135136% SETARGS Name/value parsing and assignment of varargin with default values
136137if nargin < 1 , mfile_showhelp ; return ; end
137138if nargin < 2 , optargs = []; end
138- defaults = reshape(defaults , 2 , length(defaults )/2 )' ;
139+ defaults = reshape(defaults , 2 , length(defaults )/2 )' ;
139140if ~isempty(optargs )
140141 if mod(length(optargs ), 2 )
141- error(' Optional inputs must be entered as Name, Value pairs, e.g., myfunction('' name'' , value)' );
142+ error(' Optional inputs must be entered as Name, Value pairs, e.g., myfunction('' name'' , value)' );
142143 end
143144 arg = reshape(optargs , 2 , length(optargs )/2 )' ;
144145 for i = 1 : size(arg ,1 )
@@ -149,7 +150,7 @@ function mfile_showhelp(varargin)
149150 error(' Input "%s " does not match a valid input.' , arg{i ,1 });
150151 else
151152 defaults{idx ,2 } = arg{i ,2 };
152- end
153+ end
153154 end
154155end
155156for i = 1 : size(defaults ,1 ), assignin(' caller' , defaults{i ,1 }, defaults{i ,2 }); end
0 commit comments