How can I stop my Mac showing a new figure window on MATLAB while I am doing something else?

32 vues (au cours des 30 derniers jours)
This seems like a very specific weird question that I can't find an answer to anywhere else.
I am making lots of figures in MATLAB. Lots. Hundreds. I plot each figure and then save it as a png to look at later. I am doing this in a for loop so each figure pops up for one second, saves, and then closes. On a Windows machine, I could start the for loop and then go work on other things in other programs while the MATLAB program ran. However, I am now working on a Mac and every time a new figure is opened in MATLAB, my computer jumps back to MATLAB as the active window. So it's impossible to do anything (e.g. use Safari, Preview, or any other program) while the script is running because every 1-2 seconds, MATLAB pops back up and I have to navigate back to whatever program I was using. I've tried minimizing MATLAB, I've even tried creating a new desktop in Mission Control. But it just keeps jumping back to MATLAB every time a figure opens.
I'm not sure if this is a Mac question or a MATLAB question, but I couldn't find any answers on any Mac help likely because few Mac users are opening and closing hundreds of windows.
Any help is appreciated.
I am using MATLAB 2021a on a 2019 13-in MacBook Pro with Big Sur 11.3.
  1 commentaire
Jan
Jan le 6 Juil 2021
Can you post a minimal working example? Perhaps:
pause(10); % Now you bring another program in the foreground
figure('KeypressFcn', @(h,e) disp('Here I am'))
plot(1:10);
What is in the foreground now? Matlab's command window or the figure? What happens if you press a key now? Does the message appear on the screen (a cheap test, where the focus is)?
Under Windows 10, Matlab 2018b, this does not steal the focus.

Connectez-vous pour commenter.

Réponses (1)

Walter Roberson
Walter Roberson le 6 Juil 2021
In terminal write
defaults write com.apple.dock workspaces-auto-swoosh -boolean NO
killall Dock
Now create a Desktop for isolating the windows of that MATLAB session. On the new desktop, hover over the MATLAB icon for the MATLAB session you want to affect, and right-click and select Options. At the end of the list of options (after things like "Keep in dock") you will see a list of desktops in an Assign To section. Select "This Desktop". Now windows for that MATLAB session will only open on that desktop, and with the auto-swoosh turned off, you will never be automatically switched to the desktop when there is activity there.

Catégories

En savoir plus sur Environment and Settings 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