Set default documentation location programmatically in R2021A

Starting in R2021a, when you run MATLAB with an internet connection, the Help browser displays the web documentation by default. When you run MATLAB on a system without an internet connection, or if your internet connection becomes unavailable, the Help browser displays the installed documentation instead.
To change the default documentation location, on the Home tab, in the Environment section, click Preferences. Select MATLAB > Help and change the Documentation Location.
I would like to know what is the code to change the documentation location programmatically.
I thought it was something like
com.mathworks.mlservices.MLHelpServices.setDocCenterDomain
but I could not find it
Thank you in advance
Marco

Respuestas (1)

Anmol Dhiman
Anmol Dhiman el 7 de Abr. de 2021
Hi Marco,
This is controlled by the matlab.help.DocCenterLocation setting. The valid values are "WEB" or "INSTALLED":
>> s = settings;
>> s.matlab.help.DocCenterLocation.PersonalValue = 'WEB';
Please note that this not a documented functionality and might not work in future releases.
Hope it Helps

8 comentarios

Marco Riani
Marco Riani el 7 de Abr. de 2021
Editada: Marco Riani el 8 de Abr. de 2021
Thank you very much for your message which indeed taught me something that I did not know.
Unfortunately it seems that the four options which are present inside
s=settings
s.matlab.help.DocCenterLocation
ActiveValue:<no value>
TemporaryValue: <no value>
PersonalValue: <no value>
FactoryValue: <no value>
are completely unlinked to what you set inside the
Home tab, in the Environment section, click Preferences. Select MATLAB > Help and change the Documentation Location
It seems you can write any string inside ActiveValue and PersonalValue
s.matlab.help.DocCenterLocation
ans =
Setting 'matlab.help.DocCenterLocation' with properties:
ActiveValue: 'bbb'
TemporaryValue: 'bbb'
PersonalValue: 'aaa'
FactoryValue: <no value>
with no effect on the web location of the help.
Any help is appreciated.
Thank you very much in advance
Marco
I tried it as well on MATLAB 2021a and I can confirm that this setting is not working.
Changing programmatically the documentation location between 'INSTALLED' and 'WEB' would be a really important feature, given that in the 2021a release if you choose oprion WEB -which is now the default- you cannot find the documentation of third party toolboxes.
Aldo
Instead of using s.matlab.help.DocCenterLocation
try setting s.matlab.help.DocCenterLocation21a
Also, instead of setting the PersonalValue property which will make a change to your matlab.prf file, I recommen using a startup script and within startup.m, set the TemporaryValue property which will persist until Matlab is closed. Undocumented changes to the preference file often leads to really slow startup times and other instabilities.
Dear Adam,
Thank you very much for your hints.
Indeed it seems that choosing in the Home Preferences Documentation Location “Installed Locally” sets the Active Value and Personal Value of
s=settings; s.matlab.help.DocCenterLocation21a
to INSTALLED
ActiveValue: 'INSTALLED'
TemporaryValue: <no value>
PersonalValue: 'INSTALLED'
FactoryValue: 'WEB'
Viceversa if in the Home Preferences Documentation Location one chooses option “Web on Mathworks.com” it sets the Active Value and Personal Value of
s=settings; s.matlab.help.DocCenterLocation21a to WEB
ans =
Setting 'matlab.help.DocCenterLocation21a' with properties:
ActiveValue: 'WEB'
TemporaryValue: <no value>
PersonalValue: 'WEB'
FactoryValue: 'WEB'
Now: ActiveValue is a read Only Property
s.matlab.help.DocCenterLocation21a.ActiveValue='INSTALLED'
Unable to set the 'ActiveValue' property of class 'Setting' because it is read-only.
If I change programmatically PersonalValue to INSTALLED as follows
s.matlab.help.DocCenterLocation21a.PersonalValue='INSTALLED'
it changes both ActiveValue and PersonalValue
s =
SettingsGroup with properties:
matlab: [1×1 SettingsGroup]
>> s=settings; s.matlab.help.DocCenterLocation21a
ans =
Setting 'matlab.help.DocCenterLocation21a' with properties:
ActiveValue: 'INSTALLED'
TemporaryValue: <no value>
PersonalValue: 'INSTALLED'
FactoryValue: 'WEB'
The point is that these modifications take effect just when you relaunch MATLAB.
The FINAL THING is: now that thanks to your advice I have learnt how to modify this setting programmatically, how is it possible to immediately apply programmatically the new changes without restarting MATLAB?
Setting TemporaryValue to INSTALLED does not do anything. On the other hand the modifications that you do inside Home Preferences Documentation Location immediately have an effect. The final question is: how can I obtain the same behaviour programmatically?
As far as I could see, if I am not mistaken, nothing is written in the matlab.prf file, therefore something like
pref = regexp( fileread(fullfile(prefdir,'matlab.prf')), '\n', 'split');
fid = fopen(fullfile(prefdir,'matlab.prf'), 'w');
fprintf(fid, '%s\n', pref{:});
fclose(fid);
to reapply the preferences does not work.
Any help is appreciated.
Thank you very much in advance.
The ActiveValue is read-only. If a TemporaryValue is set, the ActiveValue copies the TemporaryValue. If the Temp value is not set and the PersonalValue is set, then the ActiveValue copies the PersonalValue. If neither the Temp or Personal values are set, then the ActiveValue copies the FactoryValue. This is explained in the documentation:
So, it sounds like setting the PreferredValue is what you want to do but I don't know anything about the problem of needing to restart Matlab.
Dear Adam,
Thank you very much for your additional message.
The distinction among Active, Personal, Temporary and Factory is very clear.
The point is that while certain properties like
s.matlab.editor.language.matlab.comments.MaxWidth.TemporaryValue = 80
immediately take effect.
On the other hand something like
s.matlab.help.DocCenterLocation21a.PersonalValue='INSTALLED'
DOES NOT take effect immediately.
On the other hand the modifications that you do inside Home Preferences Documentation Location immediately have an effect and change s.matlab.help.DocCenterLocation21a.
The reverse is not true, that is a programmatic change like
s.matlab.help.DocCenterLocation21a.PersonalValue='INSTALLED'
or
s.matlab.help.DocCenterLocation21a.TemporaryValue ='INSTALLED'
has no effect on the corresponding radio buttons in the GUI (of course not even if you close and reopen the GUI MATLAB help Preferences). .
What I cannot understand yet is how do you distinguish among the properties that immediately take effect and those who need MATLAB to restart and more specifically to my problem, given that the modifications in the GUI immediately take effect, how can I obtain the same behaviour programmatically? There must be a way programmatically to do this.
Any help is appreciated.
This is just to confirm that the instruction:
s.matlab.help.DocCenterLocation21a.PersonalValue='INSTALLED'
or
s.matlab.help.DocCenterLocation21a.TemporaryValue ='INSTALLED'
does not take effect immediately. I'm using Matlab 2021a on a Mac OSX.
Thanks in advance
I confirm that for some unknow reason, the following property:
s.matlab.help.DocCenterLocation21a.PersonalValue='INSTALLED'
or
s.matlab.help.DocCenterLocation21a.TemporaryValue ='INSTALLED'
works only if you restart MATLAB. It would be nice if this was not necessary.
It also would be nice if this instant effect could become a feature request in a future MATLAB release.

Iniciar sesión para comentar.

Categorías

Más información sobre Introduction to Installation and Licensing en Centro de ayuda y File Exchange.

Productos

Versión

R2021a

Etiquetas

Preguntada:

el 1 de Abr. de 2021

Comentada:

el 17 de Dic. de 2021

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by