开发者

MATLAB: Prevent figures from being made active

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开发者_JAVA百科.

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


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

a = figure('visible','off');


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.


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).


If you want all figures to not show.

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


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜