如何控制显示哪些监视器图?

How can I control which monitor plots are displayed on?

我有一个 3 显示器 Gentoo Linux 系统 运行 MATLAB。 MATLAB 在中央监视器上运行。我需要 MATLAB 在左侧显示器上生成绘图,但它总是在右侧显示器上绘图。

我认为这至少部分是由于我的显示器物理排列方式不标准 - 基本上是 2,3,1:

>> get(0,'MonitorPositions')

ans =

           1           1        1920        1080
       -3839           1        1920        1080
       -1919           1        1920        1080

有什么方法可以控制它作为 MATLAB 中的默认值吗?

你可以set the default figure position on the root object这样:

set(0, 'DefaultFigurePosition', [-3839 1 1920 1080]);

这将创建 windows,默认填充左侧监视器。但是,每次重新启动 MATLAB 时,此默认值可能会重置,因此如果您希望它在会话之间持续存在,则必须将其放入 startup 文件中。

注:根对象的documentation for the 'MonitorPositions' property是这样说的:

The first two elements in each row indicate the display location with respect to the origin point. The last two elements in each row indicate the display size. The origin point is the lower-left corner of the primary display.

如果更改用作主显示器的监视器,左侧两列中的相对坐标将发生变化,这意味着您将不得不更改上述代码行中的位置值。如果您认为显示设置可能经常更改,或者您将在不同的监视器设置上编写 运行 代码,那么您可以通过在左栏。以下是您的操作方法(还结合了之前默认的 window 大小和监视器内的位置):

monitorPos = get(0, 'MonitorPositions');
figurePos = get(0, 'DefaultFigurePosition');
[~, leftIndex] = min(monitorPos(:, 1));
set(0, 'DefaultFigurePosition', figurePos + [monitorPos(leftIndex, 1:2)-1 0 0]);