Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Move all figures to a specific monitor in MATLAB

Tags:

matlab

I was wondering if there is any known way of moving MATLAB figures to a specific monitor.

I have the following snippet that helps me bring all figures to the front (I got it from Mathworks here):

%% Bring all figures to front
all_figure_handles = findall(0, 'type', 'figure');
for iCount = length(all_figure_handles):-1:1
   figure(all_figure_handles(iCount))
end

And I was wondering if I could ask MATLAB to move all figures to another screen in a similar fashion (i.e. using the handles from all_figure_handles).

Alternatively, if MATLAB is not aware of the monitor partitioning, how could I move all figures to, say, the right half of the total screen space? (in my case, the right half should be the monitor on the right).

like image 835
Amelio Vazquez-Reina Avatar asked Oct 11 '11 20:10

Amelio Vazquez-Reina


1 Answers

From the Matlab figure documentation:

Specifying Figure Size and Screen Location

To create a figure window that is one quarter the size of your screen and is positioned in the upper left corner, use the root object's ScreenSize property to determine the size. ScreenSize is a four-element vector: [left, bottom, width, height]:

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

To position the full figure window including the menu bar, title bar, tool bars, and outer edges, use the OuterPosition property in the same manner.

Like this:

set (gcf(), 'outerposition', [25 500, 560, 470])

And furthermore, in the documentation for Root Properties:

MonitorPositions

[x y width height;x y width height]

Width and height of primary and secondary monitors, in pixels. Contains the width and height of each monitor connnected to your computer. The x and y values for the primary monitor are 0, 0 and the width and height of the monitor are specified in pixels.

The secondary monitor position is specified as: x = primary monitor width + 1 y = primary monitor height

Querying the value of the figure MonitorPositions on a multiheaded system returns the position for each monitor on a separate line. v = get(0,'MonitorPositions') v = x y width height % Primary monitor x y width height % Secondary monitor

The value of the ScreenSize property is inconsistent when using multiple monitors. If you want specific and consistent values, use the MonitorPositions property.

like image 150
Max Avatar answered Oct 19 '22 15:10

Max