1

I have a rather large routine which will can run for a couple of hours. Here and there it creates a figure, plots something to it and saves that Figure.

As I have only one PC, I would like to continue to work with that machine. The problem is that whenever a new figure is made, MATLAB becomes the active application again. Is there any way to tell MATLAB or Windows that MATLAB should not be allowed to set itself to active?

I saw that one possibility is to run a MATLAB script totally in the background (like that). But that is a little bit too unsupervised, as I would like to be able to switch to the MATLAB window and check the output to the command window.

Any ideas? If there is a general solution for Windows that prevents that other Applications to become active would also be cool!

2
  • What do you mean by active? That the figure window pops in front of whatever you are working on?
    – Ghaul
    Commented Feb 23, 2011 at 10:31
  • What version of Windows? Behavior preventing background applications from stealing focus is built in these days.
    – Ben Voigt
    Commented Feb 23, 2011 at 19:23

5 Answers 5

1

You can overload the figure function as following in order to prevent figure poping up:

a = figure('visible','off');
1
  • Introduces some other problems (seems like uicontrol does not like beeing unvisible), but it works!
    – Thomas
    Commented Feb 23, 2011 at 13:19
1

I hate to state the obvious, but you could always store the data you want to plot until the end.

Now, you're going to tell me that some of that data is subroutines and doesn't get passed back to the main routine. OK. So, the solution to that would be to write a "Store_Plot_Data" class with a method that would write into memory the data, the @plot_function_name (for 3D, scatter, etc.), the axis label strings, etc. Then you would create one instance of this class in your main routine and to ensure visibility of this one instance to all subroutines you could do any of the following:

  1. use a global variable as your single instance ... OK, not so elegant,

  2. implement the Singleton pattern, or

  3. pass all subroutines the handle to that one instance of the "Store_Plot_Data" class.

1
  • That could work also, yes (my original problem is long resolved :D), but again printing and saving figures is rather slow and saving a couple of hundred figures still would take a considerable amount of time (and therefore disturbance if I wanna do something else on the side)
    – Thomas
    Commented Feb 17, 2015 at 20:27
0

If there is a general solution for Windows that prevents that other Applications to become active would also be cool!

In Windows 7, this worked for me:

http://pcsupport.about.com/od/windowsxp/ht/stealingfocus02.htm

Set "HKEY_CURRENT_USER\Control Panel\Desktop\ForegroundLockTimeout" to 30d40 (hex).

0

If you want all figures to not show.

set(0,'defaultFigureVisible','off'); 
0

In the beginning of your script do:

set(0, 'DefaultFigureVisible', 'off');
set(0, 'DefaultFigureWindowStyle', 'docked');

Dock the Matlab figure window and maximize any other application (Excel, Word etc.) you are working with in front of Matlab.

Then you can continue to work without being interrupted by figures blinking on your face.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.