framelab.m

来自「有关matlab的电子书籍有一定的帮助希望有用」· M 代码 · 共 34 行

M
34
字号
function fl = framelab(framehand,labelstr,lfs,lh,varargin)
% FRAMELAB Create UIControl of style static text for frame label.
%   Assumes all positions and units are in pixels.
%   Inputs:
%     framehand - handle of frame
%     labelstr - string
%     lfs - spacing between label text and left edge of frame
%     lh - label height 
%     varargin{:} - param/value pairs for uicontrol creation
%   Outputs:
%     fl - frame label handle
 
%   Copyright (c) 1988-98 by The MathWorks, Inc.
% $Revision: 1.8 $

    pos = get(framehand,'position');

    lpos = [pos(1)+lfs pos(2)+pos(4)-lh/2 100 lh];
    
    l = uicontrol('style','text',...
          'units','pixels',...
          'string',[labelstr ' '],...
          'position',lpos,varargin{:});

    ex = get(l,'extent');

    set(l,'position',[lpos(1:2) ex(3) lpos(4)])
    set(l,'horizontalalignment','center')

    if nargout > 0
        fl = l;
    end

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?