In MATLAB, how do I obtain information about my screen resolution and screen size?
Show older comments
Using MATLAB, I want to obtain information about my screen resolution and screen size.
Accepted Answer
More Answers (2)
Dominik Mattioli
on 18 Dec 2018
Res = get(0,'ScreenPixelsPerInch')
This functionality might have been added since MathWorks originally posted their own answer above.
broken_arrow
on 10 Oct 2021
Edited: MathWorks Support Team
on 11 Nov 2025
Concerning size measures in plotting, the fixed "virtual" DPI value on Windows or Linux systems returned by
get(0,'ScreenPixelsPerInch')
means that setting e. g.
figure('Units','pixels','Position',[0 0 1920 1080])
equals a figure size of 1920x1080 screen pixels if the "true" monitor DPI is less than or equal to that "virtual" value (meaning that on a 1920x1080 monitor, the figure will cover the entire screen). For monitors with a true DPI greater than the virtual one, the number of screen pixels per "unit pixel" increases accordingly (props to Walter): https://www.mathworks.com/help/matlab/develop-apps-programmatically.html (thus on a 4K monitor of same size, the aforementioned figure would still cover the whole screen).
The true monitor DPI can be easily calculated manually (Pythagorean theorem) or with an online tool (google "calculate monitor dpi")
1 Comment
Walter Roberson
on 10 Oct 2021
96 is used for Windows. For MacOS it is 72.
Categories
Find more on Environment and Settings in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!