MATLAB Answers

0

Resolution changed while matlab running, figure positioning no longer accurate

Asked by Alex R. on 10 Mar 2014
Hi,
I've searched on this but didn't find much. Suppose I start Matlab on a screen resolution of 1680x1050. Then, while Matlab is still running, I change the resolution to 1280x800 ... same happens if I remote login to the machine via RDP, requesting 1280x800. I'm using Windows 8.1 x64 and the behaviour below applies to Matlab 2013b and also 2014a pre-release.
Matlab caches and uses the initial 1680x1050 resolution when positioning figures, which results in all sort of artifacts.
I know how I can read the actual screen res by doing pos = get(0,'MonitorPositions') which gives [1 1 1280 800] (or by using Java calls) instead of get(0,'ScreenSize') which gives [1 1 1680 1050. However, when using figure() or set(gcf,...) to offset my figures then it still uses the former values, so stuff like the following does not give the expected result:
>> pos = get(0,'MonitorPositions')
pos =
1 1 1280 800
>> figure('units','pixels','position',[pos(3)/2 50 640 480])
Then the first two coordinates (the offset) are still interpreted with respect to the cached resolution 1680x1050 instead of the current 1280x800 resolution, so my figure is way off ... if the figure is small, it does not show at all (50 pixels off the bottom of 1050 which is below 800).
Is there a way to make figure() aware of the current resolution without restarting Matlab?
Cheers, Alex.

  0 Comments

Sign in to comment.

0 Answers