In MATLAB, how do I obtain information about my screen resolution and screen size?
Afficher commentaires plus anciens
Using MATLAB, I want to obtain information about my screen resolution and screen size.
Réponse acceptée
Plus de réponses (2)
Dominik Mattioli
le 18 Déc 2018
Res = get(0,'ScreenPixelsPerInch')
This functionality might have been added since MathWorks originally posted their own answer above.
broken_arrow
le 10 Oct 2021
Modifié(e) : MathWorks Support Team
le 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 commentaire
Walter Roberson
le 10 Oct 2021
96 is used for Windows. For MacOS it is 72.
Catégories
En savoir plus sur Environment and Settings dans Centre d'aide et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!