Matlab Linux Dual Monitor Issue

12 vues (au cours des 30 derniers jours)
Lizz Cooper
Lizz Cooper le 23 Mai 2022
Commenté : E S le 2 Sep 2022
We are trying to get Matlab running on Linux to display our output correctly. When we run the code - it is conjoing both monitors (each 1920 x 1080) as 3840 on the horizontal axis (verital unaffected) causing the output to appear in the center of both monitors as if it was ONE monitor. We would like it to display on one monitor only so we can use the other monitor to observe. Anybody have any ideas? Appreciate all the help!
  1 commentaire
E S
E S le 2 Sep 2022
Did you ever resolve this without a kludge? I just moved my workstation over to linux and see the same thing, two 4k monitors being reported by get(0,'MonitorPositions') as a single 7680 by 2160 monitor. All new figures (unless given explicit location) appear on the seam between the two monitors, which is annoying.

Connectez-vous pour commenter.

Réponses (1)

Voss
Voss le 23 Mai 2022
Maybe explicitly set the Position of the output figure(s).
Check the MonitorPositions that MATLAB is using:
get(groot(),'MonitorPositions')
ans = 1×4
1 1 1920 1200
and set the figure Position(s) accordingly.
  2 commentaires
Lizz Cooper
Lizz Cooper le 24 Mai 2022
I appreciate your help. So, how would I set it so that the output only uses one monitor? Please see the picture attached. Thank you so much for your help!
Voss
Voss le 24 Mai 2022
Modifié(e) : Voss le 24 Mai 2022
I'm not familiar with EEGLAB (if that is in fact the code that's creating the figures in the middle of the two monitors), but, regardless, you can try something like this.
The idea is to set the figure Position after the figure is created. This will move the figure to be centered in the left monitor, keeping the size of the figure as it is. (Code to move it to be centered in the right monitor is there too, commented out.)
% get the handle to the current figure
f = gcf();
% [if that doesn't work (returns empty f or returns the wrong figure),
% try using findall(), like one of these:]
% f = findall(groot(),'Type','figure','Name','EEGLAB');
% f = findall(groot(),'Type','figure');
% f = f(1); % pick the correct figure from the ones returned
% need the figure Position in groot Units, to compare against MonitorPositions
f_units = get(f,'Units');
m_units = get(groot(),'Units');
if ~strcmp(f_units,m_units)
set(f,'Units',m_units);
end
% figure Position in m_units
f_pos = get(f,'Position');
% MonitorPositions in m_units
m_pos = get(groot(),'MonitorPositions');
% get the center location of the left monitor
m_center = m_pos(1,[1 2])-1+[m_pos(1,3)/4 m_pos(1,4)/2];
% (or the center location of the right monitor)
% m_center = m_pos(1,[1 2])-1+[3*m_pos(1,3)/4 m_pos(1,4)/2];
% now move the figure to be centered at m_center
set(f,'Position',[m_center-f_pos([3 4])/2 f_pos([3 4])]);
% restore figure Units to old value, if necessary
if ~strcmp(f_units,m_units)
set(f,'Units',f_units);
end
It's also possible that restarting MATLAB will get the command
get(groot(),'MonitorPositions')
to return the correct MonitorPositions, since that's updated only when MATLAB starts (i.e., this behavior could be a problem caused by connecting the second monitor after MATLAB was started). If that works, then you don't need to worry about the code above (and, presumably, EEGLAB or whatever code creates the figure will also set the position more appropriately).

Connectez-vous pour commenter.

Catégories

En savoir plus sur Graphics Performance dans Help Center et File Exchange

Tags

Produits


Version

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by