align_figure.m
来自「一个matlab的将军模型」· M 代码 · 共 49 行
M
49 行
function align_figure(fig,valign,halign)
screen_size = get(0,'ScreenSize');
screen_width = screen_size(3); screen_height = screen_size(4);
pos = get(fig,'Position');
left = pos(1); bottom = pos(2);
width = pos(3); height = pos(4);
if strcmp(get(fig,'MenuBar'),'none')
offset = 20;
menus = findobj(get(fig,'Children'),'type','uimenu');
for k = 1:length(menus)
if strcmp(get(menus(k),'Visible'),'on')
offset = 40;
break;
end
end
else
offset = 40;
end
switch valign
case 'top'
bottom = screen_height-height-offset;
case 'center'
bottom = (screen_height-height-offset)/2;
case 'bottom'
bottom = 0;
otherwise
error(['Invalid vertical alignment ''' halign '''.'])
end
switch halign
case 'left'
left = 0;
case 'center'
left = (screen_width-width)/2;
case 'right'
left = screen_width-width;
otherwise
error(['Invalid horizontal alignment ''' halign '''.'])
end
set(fig,'Position',[left bottom width height]);
return
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?