不确定我是否误解了您的问题,但您可以使用figposition 函数获取当前分辨率。例如在我的笔记本电脑上:
>> figposition([0, 0, 100, 100])
ans =
0 0 1366 768
表示分辨率为 1366x768
然后您可以set(gcf,'position', ... ) 到您想要的位置,使其处于中心位置。
你甚至可以直接在里面使用figposition,事实上,直接使用百分比来set这个数字的位置。
** 编辑:** 一个示例,根据要求:
% Create Figure Window (e.g. by app designer; it's still a normal figure)
MyGuiWindow = figure('name', 'My Gui Figure Window');
% Desired Window width and height
GuiWidth = 500;
GuiHeight = 500;
% Find Screen Resolution
temp = figposition([0,0,100,100]);
ScreenWidth = temp(3);
ScreenHeight = temp(4);
% Position window in center of screen, and set the desired width and height
set (MyGuiWindow, 'position', [ScreenWidth/2 - GuiWidth/2, ScreenHeight/2 - GuiHeight/2, GuiWidth, GuiHeight]);