patrik
patrik

Reputation: 4558

Set default docking location for figures

I have learned how to dock figure by default in matlab. This can be done adding this line to the startup function:

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

This is for example found in the matlab blog.

However, this command makes the figure appear on top of my text editor, which is docked as well. What I want to do is to dock the figure in the upper right quadrant in the matlab workspace. Is there anyway to do this?

Note: I am not sure if it is possible to set the layout using the tip from SO 2011-08-02, but I am not interested in changing matlabs default settings; Only to alter them with the startup function. It is then easy to restore these settings by just removing them from the startup function.

Upvotes: 3

Views: 1893

Answers (1)

Sam Roberts
Sam Roberts

Reputation: 24127

Here is a bit of undocumented stuff that may work for you. It may well not work in all versions of MATLAB, but it seems to work OK in a couple of recent versions that I just tested it on.

Firstly, arrange the desktop components in the way you'd like them to start up (including positioning and docking the Figures group). Then from the Layout menu on the Home tab, save the current layout - let's imagine you save it with the name mylayout.

Now move everything around a bit.

Type a = com.mathworks.mde.desk.MLDesktop.getInstance to get a reference a to the MATLAB desktop. You now have access to some methods of a that can rearrange its components.

In particular, you can call a.restoreLayout('mylayout') to reapply the original layout. If there are no figures currently visible, the Figures group won't be present, but you can open an empty Figures group with a.showGroup('Figures',true).

You should be able to include these commands in your startup.m file to arrange things as you like at startup.

To find more about how to play around with these things, type methodsview(a) and you'll get a list of all the stuff you can do to the desktop programmatically.

Please note that this is undocumented, so don't rely on it for anything important. In addition, it's likely that this functionality won't work in all releases of MATLAB and will change from release to release as MathWorks continue to improve the desktop environment.

Upvotes: 1

Related Questions