Path: news.mathworks.com!not-for-mail
From: "Diederick " <dcniehorsterDEL@hkuDEL.hkDEL>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Changing preferences from command line
Date: Thu, 19 Nov 2009 03:02:03 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 75
Message-ID: <he2cfb$42d$1@fred.mathworks.com>
References: <f9vhri$orl$1@fred.mathworks.com> <fa415r$kk8$1@fred.mathworks.com> <fa48lm$834$1@fred.mathworks.com>
Reply-To: "Diederick " <dcniehorsterDEL@hkuDEL.hkDEL>
NNTP-Posting-Host: webapp-02-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1258599723 4173 172.30.248.37 (19 Nov 2009 03:02:03 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Thu, 19 Nov 2009 03:02:03 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1895497
Xref: news.mathworks.com comp.soft-sys.matlab:586298


Hi,

I'm pretty happy with the below "undocumented" functionality. Got myself a nice m-file now can run to get a new desktop looking like i want it too (i prefer light text on a dark background for instance). However, it seems not all preferences are actually in the matlab.prf file. Specifically, I am trying to do settings for cell highlighting, those two checkboxes and one color do not seem to be in the preferences file. I'm on R2009b, but I suppose any older version wouldn't have them too.

Does anybody know where to find them / if it is possible to set them by commands?

If anybody is interested in my configuration script, I can paste it in on request.

Best and thanks!
Dee

"Yair Altman" <altmanyDEL@gmailDEL.comDEL> wrote in message <fa48lm$834$1@fred.mathworks.com>...
> "Titus" <titus.edelhofer@mathworks.de> wrote in message
> <fa415r$kk8$1@fred.mathworks.com>...
> > For other preferences: probably Yair could come up with
> some > java call, I don't know of some "official" way...
> 
> 
> Thanks for the compliment - I couldn't resist the challenge...
> 
> * The preferences are stored in the matlab.prf text file
> that's stored in the user's Matlab preferences folder
> (prefdir is a built-in Matlab function):
> 
> edit(fullfile(prefdir,'matlab.prf'));
> 
> Each preference appears to be on a separate line in the
> following format: <pref-name>=<pref-type><pref-value>
> 
> <pref-type> appears to be one of these:
>   - 'B' => boolean/logical flag
>   - 'C' => color (RGB numeric value)
>   - 'F' => font (type,size,name)
>   - 'I' => int16
>   - 'J' => int32
>   - 'R' => rectangular area
>   - 'S' => string/char
> 
> examples: 
>   EditorShowLineNumbers=Btrue
>   EditorMaxCommentWidth=I120
> 
> * You can read the preference names from this matlab.prf
> file and then use the following (you-guessed-it) java calls
> to get/set the values:
>   - com.mathworks.services.Prefs.get<type>Pref(<pref-name>)
>   -
> com.mathworks.services.Prefs.set<type>Pref(<pref-name>,newValue);
> 
> <type>: one of Boolean, Color, RGBColor, Font, Integer,
> Rectangle, String, Double (I believe Doubles get converted
> to int32 - possibly a bitwise casting since both use 32 bits)
> 
> For example:
> com.mathworks.services.Prefs.getBooleanPref('LayoutSnapToGrid')
> com.mathworks.services.Prefs.getIntegerPref('GeneralNumComputationalThreads')
> 
> adding a second argument to get<type>Pref() appears to
> indicate a default value that is returned if <pref-name> is
> invalid:
> com.mathworks.services.Prefs.getIntegerPref('xxxx',123)
> => 123
> 
> * STRONG WARNING: all this relies on a lot of guesswork,
> trial-&-error and some common sense. It's absolutely
> undocumented, unsupported and discouraged by MathWorks.
> You're pretty safe as long as you stick to read-only mode.
> But if you try modifying system values this way, well it
> might blow in your face if you try it at home or on a system
> even slightly different than the one I have (WinXP, 2007a).
> Don't come crying if your Matlab prefs get all screwed up... 
> 
> Yair Altman
> http://ymasoftware.com
>