how MATLAB determines order of monitors

4 vues (au cours des 30 derniers jours)
André
André le 21 Jan 2024
Modifié(e) : André le 29 Fév 2024
Does anyone know how MATLAB determines the order of the monitors, when multiple monitors are connected?
I did this:
>> get(0, 'MonitorPositions')
ans =
-1919 -2182 1920 1080
1 1 1536 864
Why isn't the monitor whose position starts with (1,1) the first? My Windows settings clear state that this monitor is the principal one. Even if I go to Windows settings and rearranje the monitors (left-right), nothing changes (only the coordinates change). And if I set the secondary monitor as the principal one, nothing changes either.
Restarting MATLAB does not solve the issue (only the coordinates change).
Restarting Windows does not solve the issue (only the coordinates change).
I need a consistent way to identify each monitor being used by MATLAB.

Réponses (1)

Taylor
Taylor le 23 Jan 2024
Can you share the values you get when restarting MATLAB and Windows? It's hard to tell exactly why the (1, 1) monitor isn't the first index, but it may be as simple as they sort the indexes based on the x-position. I have two monitors and this is my return:
get(0, "MonitorPositions")
ans =
1 1 1920 1080
1921 1 1920 1080
My primary monitor is on the left so this ordering makes sense to me. I'm wondering if your primary monitor is on the right which is why you're seeing negative position values.
  1 commentaire
André
André le 28 Fév 2024
Modifié(e) : André le 29 Fév 2024
Lets call integrated monitor A, and external monitor B.
Lets call primary monitor 1 and secondary monitor 2.
Lets call left monitor L and right monitor R.
Here are the combinations:
1-A-L, 2-B-R:
>> get(0, "MonitorPositions")
ans =
1921 -215 1920 1080
1 1 1536 864
1-A-R, 2-B-L:
>> get(0, "MonitorPositions")
ans =
-1919 -215 1920 1080
1 1 1536 864
Regardless of what happens, montitor A comes always in second row of the array, even when it is the primary monitor. It should come in first row, not second, because IT IS THE INTEGRATED MONITOR, not the external one.
Coordinates are correct, but row positions in the array are wrong.
Lets now swap the main monitor:
2-A-L, 1-B-R:
>> get(0, "MonitorPositions")
ans =
1 1 1920 1080
-1919 217 1536 864
2-A-R, 1-B-L:
>> get(0, "MonitorPositions")
ans =
1 1 1920 1080
1921 217 1536 864
Monitor A remains in second row, even after flipping everything. I want monitor A to be in first row of the array, because it is the primary monitor.
Restarting MATLAB or windows does not solve the issue.
BTW, if I disconect the external monitor and connect a different one, the problem is solved. But when I connect this monitor again, the problem returns.
MATLAB is being extremely stubborn, and keeps putting the primary monitor in second row of the array, but this only happens when a specific secondary monitor is connected.

Connectez-vous pour commenter.

Catégories

En savoir plus sur Function Creation dans Help Center et File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by