0001 function SplitTitle(h,text,width)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023 if nargin < 1,
0024 error('Incorrect number of parameters (type ''help <a href="matlab:help SplitTitle">SplitTitle</a>'' for details).');
0025 end
0026
0027
0028 if nargin == 1,
0029 text = h;
0030 h = gca;
0031 width = 10;
0032 elseif nargin == 2,
0033 if ishandle(h),
0034 width = 10;
0035 else
0036 width = text;
0037 text = h;
0038 h = gca;
0039 end
0040 end
0041
0042 if ~isiscalar(width),
0043 error('Non-integer width (type ''help <a href="matlab:help SplitTitle">SplitTitle</a>'' for details).');
0044 end
0045
0046
0047 l = length(text);
0048 nLines = ceil(l/width);
0049 start = -width+1;
0050 t = {};
0051 for i = 1:nLines-1,
0052 start = (i-1)*width+1;
0053 t{i} = text(start:start+width-1);
0054 end
0055 t{end+1} = text(start+width:end);
0056
0057
0058 switch lower(get(h,'type')),
0059 case 'uipanel',
0060 set(h,'title',t);
0061 case 'axes',
0062 title(h,t);
0063 end