Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How can I find determine the monitor resolution using a matlab command?

514 views
Skip to first unread message

Jens Koopmann

unread,
Nov 10, 2008, 12:45:04 PM11/10/08
to
As the title says I want to determine the dimensions of the monitor resolution and then to feed that into my GUI so that opens in the max resolution.

Kind regards

Jens

Walter Roberson

unread,
Nov 10, 2008, 1:25:08 PM11/10/08
to
Jens Koopmann wrote:
> As the title says I want to determine the dimensions of the monitor resolution

In Matlab, the dimension of the monitor resolution is always
pixels per inch; there is no corresponding metric measurement provided.

>> get(0,'ScreenPixelsPerInch')
ans =

90

> and then to feed that into my GUI so that opens in the max resolution.

This is where it starts to get confusing. There is

>> get(0,'ScreenSize')
ans =

1 1 1280 1024

But there is also

>> get(0,'MonitorPositions')
ans =

0 0 1280 1024

Only a single vector is shown here in my output, but if you had multiple
monitors, then ScreenSize would know the -size- of each one, and
MonitorPositions would know how they were positioned relative to each
other. If you do have multiple monitors, then there are at least four
competing meanings of "max resolution": the resolution of the "first"
monitor; the resolution of the "largest" monitor; the size that
would be achieved if all the monitors were chained together vertically
(or horizontally) [and if they aren't all the same resolution what then?);
or the bounding box that takes into account the relative positions of the
monitors (there can, after all, be logical gaps between what the monitors
are showing.)


Then there is another issue: if you are using GUIDE, then unless you
are apply just the right callback at just the right time, then GUIDE will
"helpfully" resize your GUIs after you have carefully told it exactly the
size you want. (For some reason, this "feature" always reminds me of "Clippy").


--
.signature note: I am now avoiding replying to unclear or ambiguous postings.
Please review questions before posting them. Be specific. Use examples of what you mean,
of what you don't mean. Specify boundary conditions, and data classes and value
relationships -- what if we scrambled your data or used -Inf, NaN, or complex(rand,rand)?

Jens Koopmann

unread,
Nov 10, 2008, 4:04:03 PM11/10/08
to
Walter,

Brilliant reply. I will test it out and report back. You have even covered questions I haven't asked yet. But I agree nowadays it is common to own computers with multiple screens.

Kind regards

Jens

Jens Koopmann

unread,
Nov 11, 2008, 10:47:02 AM11/11/08
to
There is also this command which does exactly what I want

scrsz = get(0,'ScreenSize');
figure('Position',[1 scrsz(4)/2 scrsz(3)/2 scrsz(4)/2])


"Jens Koopmann" <jens.k...@live.com> wrote in message <gfa7k3$ao3$1...@fred.mathworks.com>...

Jens Koopmann

unread,
Nov 11, 2008, 1:18:01 PM11/11/08
to
This commands will adjust the size of the current GUI to the monitor resolution.


scrsz = get(0,'ScreenSize')

h = gcf
set(h,'Position',[10 10 scrsz(3) scrsz(4)]);

0 new messages