我专门使用连接到笔记本电脑的外接显示器(笔记本电脑的屏幕已关闭)。当我试图让MATLAB图形适合屏幕时,它只会变得足够大,以适应笔记本电脑屏幕(分辨率较低)。我使用以下内容:
figure('outerposition',get(0,'screensize')); % or 'monitorpositions'
我甚至尝试过:
figure('outerposition',[0 0 1 1.2]);
但它没有这样做,而且这个数字只适合显示器屏幕的一部分。
任何帮助都会非常感激,因为我没有想法。
P.-S。我最想做的是让一个数字适合90%(例如)的屏幕(宽度和高度)。
提前致谢!
答案 0 :(得分:1)
问题可能与this note in the documentation:
有关MATLAB在启动时设置此属性的显示信息值。值是静态的。如果系统显示设置更改,则值不会更新。要刷新值,请重新启动MATLAB。
在我的桌面上,只用一个活动屏幕启动Matlab即可:
>> get(0,'MonitorPositions')
ans =
1 1 1280 1024
即使我稍后尝试激活屏幕,也不会改变。但是,如果我激活第二个屏幕然后重新启动Matlab,我会得到:
>> get(0,'MonitorPositions')
ans =
-1919 -123 1920 1080
1 1 1280 1024
然后我可以将数字设置为这个大小:
figure('OuterPosition',[-1920 -123 3200 1080]);
涵盖两个屏幕。
答案 1 :(得分:1)
此解决方案基于Doug Schwarz在this Newsreader thread中编写的screensize
函数。
我做了一些快速测试,它似乎返回了预期的结果,在这篇文章的底部找到了我的改编。
全屏,监控2
% Pass the monitor number to the screensize function, this example uses monitor 2
sz = screensize(2);
% The function returns pixel values, so must use units pixels
% Set the outerposition according to that.
figure('units', 'pixels', 'outerposition', sz)
只需填充90%的屏幕,监控2:
sz = screensize(2);
pad = 0.05; % 5% padding all around
szpadded = [sz(1:2) + sz(3:4)*pad, sz(3:4)*(1-2*pad)];
figure('units', 'pixels', 'outerposition', szpadded);
screensize
功能function ss_out = screensize(screen_number)
%screensize: return screen coordinates of multiple monitors.
% Version: 1.0, 26 June 2008 Author: Douglas M. Schwarz
% Version: 1.1, 21 July 2017 Author: Wolfie
persistent myss
if isempty(myss)
% Get Screen Devices array.
sd = java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment.getScreenDevices;
% Initialize screensize array.
num_screens = length(sd);
myss = zeros(num_screens,4);
% Loop over all Screen Devices.
for ii = 1:num_screens
bounds = sd(ii).getDefaultConfiguration.getBounds;
myss(ii,:) = [bounds.x, bounds.y, bounds.width, bounds.height];
end
end
num_screens = size(myss,1);
if nargin == 0
screen_number = 1:num_screens;
end
screen_index = min(screen_number,num_screens);
ss_out = myss(screen_index,:);
end