Configure MATLAB programmatically

Since MathWorks releases a new version of MATLAB every six months, it is a bit of a hassle to install the latest version every time. I would like this to be an automatic way of configuring MATLAB to save time on an administrative hassle. The kinds of things I usually do when I get a new version:

  • Add commonly used directories to path.

  • Create shortcuts on the toolbar.

  • Change some of the GUI settings.

The first task is easy to accomplish programmatically using addpath

and savepath

. The next two are not that easy.

The details of the shortcuts are stored in the shortcuts.xml file in the specified folder prefdir

. My best idea so far is to use one of the XML toolboxes in the central MATLAB Exchange File Exchange to read in this file, add some shortcuts, and write them back to the file. This seems to be quite complicated and it usually means that I missed an existing utility function. Is there an easier way (programmatically) to add shortcuts?

Changing the GUI settings seems even more difficult. preferences

just opens the GUI settings editor (equivalent to file -> Settings); setpref

doesn't seem to cover GUI capabilities.

GUI settings are saved in matlab.prf

(again in prefdir

); this time in the traditional name=value

config style . I could try to rewrite the values ​​in this directly, but it's not always clear what each line does, or how much the names differ from each other, or how broken MATLAB will be if this file contains dodgy values. I understand this is a long shot, but is the content matlab.prf

documented anywhere? Or is there a better way to customize the GUI?

For more information, how did you create your copy of MATLAB? Are there any other tweaks I've missed that can be changed with a script?

+2


a source to share


2 answers




+2


a source


I am not using scripts at the moment, although that sounds like a very interesting idea.

If there are no new features that you also want to customize, you can simply copy-paste the old settings into the new prefdir. I assume this should be done programmatically, although you may need to select the old prefeed via uigetdir

. So far this has not posed any major problems for me. Please also note that any software version must be rewritten if the preference structure changes significantly.



I add paths every time I run, so I don't have to think about manually adding new directories every time I change something in my codebase (and I don't have to update directory structures for every user). So I also need to copy-paste startup.m

for each installation.

If I had to do everything manually, I would also like to change the autosave settings for storing files in a directory autosave

. If I remember correctly, Matlab reads the colors and fonts of the previous installations, so I don't need to do this.

+1


a source







All Articles