필터 지우기
필터 지우기

Getting screen resolution on Windows 11

조회 수: 6 (최근 30일)
Roger Breton
Roger Breton 2024년 5월 28일
댓글: Benjamin Kraus 2024년 5월 30일
Are there other functions I can use to get the monitor resolution on Windows 11? I use this code:
set(0, 'units', 'pixels'); % Sets the units of your root object (screen) to pixels
Pix_SS = get(0, 'screensize'); % Obtains the pixel information
And all I get is 1920 x 1080? This Dell U4320Q is 3840 x 2160 as shown in this Settings > Display resolution:
  댓글 수: 4
Rik
Rik 2024년 5월 29일
From what I recall (from discussions when display scaling was new in windows), this parameter is poorly communicated to programs.
But it everything is off by the same factor, is there a problem for your application?
An additional note: Java will be removed from Matlab somewhere in a future release. It is also generally undocumented, meaning it may change release to release without warnings in the release notes.
Benjamin Kraus
Benjamin Kraus 2024년 5월 30일
@Rik: While MATLAB will no longer include Java by default, it will still be usable from within MATLAB, but the user will be responsible for providing their own Java. Using Java within MATLAB is fully documented. For example, this documentation page discusses use of your own Java classes within MATLAB: Call Java from MATLAB

댓글을 달려면 로그인하십시오.

답변 (1개)

Benjamin Kraus
Benjamin Kraus 2024년 5월 30일
편집: Benjamin Kraus 2024년 5월 30일
Note that this is undocumented and not guaranteed to work indefinitely, but there is a property on all figures called ScreenPixelsPerInch that is similar to the property of the same name on groot, but while the value on groot takes into account the display scaling, the value on Figure does not. You can use this to get a conversion factor for the ScreenSize or MonitorPositions properties on groot.
For example:
f = figure;
scaledDPI = groot().ScreenPixelsPerInch % On my machine this is 96
unscaledDPI = f.ScreenPixelsPerInch % On my machine this is 144 because I have 150% scaling.
scaleFactor = unscaledDPI./scaledDPI % On my machine this is 1.5 because I have 150% scaling.
scaledMonitorPositions = groot().MonitorPositions % On my machine this is [1 1 2560 1440; -2559 -5 2560 1440]
% When doing the conversion, the first two values (left and bottom) are
% 1-based, so you need to subtract 1, do the scaling, then add 1.
unscaledMonitorPositions = (scaledMonitorPositions-[1 1 0 0]).*scaleFactor+[1 1 0 0]
On my machine (which runs Windows with 150% display scaling), the Figure's ScreenPixelsPerInch reports 144, while groot reports 96, which reflects the 150% scaling. Using the code above, I get the correct actual resolution of my two monitors (3840 x 2160).

카테고리

Help CenterFile Exchange에서 Programming에 대해 자세히 알아보기

제품


릴리스

R2023a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by