Set Add-ons path using commands

Hi,
I'm interested in setting the Add-ons path using commands rather than going through the MATLAB preferences dialog. Is there a way to do this?
Thanks
Alan

답변 (1개)

Henry Giddens
Henry Giddens 2017년 9월 30일

1 개 추천

댓글 수: 6

aL
aL 2017년 10월 4일
That doesn't control where add-ons are installed. It appears the MATLAB command: preferences('Add-Ons') always brings up the gui to let the user type/select the path. I want to script it so that it is set automatically.
Henry Giddens
Henry Giddens 2017년 10월 30일
Oh sorry, I completely misread the question. I wonder if you've figured it out yet? Does this help?
https://undocumentedmatlab.com/blog/changing-system-preferences-programmatically
Hi Henry,
Thanks for trying. Unfortunately Add-On preferences are not stored in that file. I actually have no idea where they are stored.
However, I did find a (rather unstable) solution. After hunting around in MATLAB functions for setting different preferences, I found a Settings/settings command (depending on which version of MATLAB). It returns a handle to MATLAB settings, though most of the properties are hidden. After some trial and error, I figured out how to change the Add-on path. However, I've also discovered that the ability to apply my solution is limited to the version of MATLAB. This is what I came up with for the different versions of MATLAB I have access to:
try
s = Settings;
try % R2016
set(s.matlab.addons,'InstallationFolder',addonpath)
catch % R2015
set(s.matlab.apps,'AppsInstallFolder',addonpath)
end
catch % R2017
s = settings;
s.matlab.addons.InstallationFolder.PersonalValue = addonpath;
end
John Harris
John Harris 2017년 12월 27일
편집: John Harris 2018년 9월 12일
Thanks for that, aL! I was only needing to get the current value but running into the same problem. You saved me a lot of time!
For the S/s issue with settings, could you try out this command?
matlab.internal.getSettingsRoot
To clarify, for 2017b:
rootSettings = matlab.internal.getSettingsRoot
folder = rootSettings.matlab.addons.InstallationFolder.ActiveValue
returns these
rootSettings =
SettingsGroup with properties:
connector: [1×1 SettingsGroup]
Simulink: [1×1 SettingsGroup]
installedAddons: [1×1 SettingsGroup]
slhistory: [1×1 SettingsGroup]
folder =
'C:\Users\harrisj2\Documents\MATLAB\Add-Ons'
I don't have better solution for the change from 'AppsInstallFolder' to 'InstallationFolder' that you detected at R2016; the try/catch works well for that.
John Harris
John Harris 2018년 1월 4일
One place the add-ons directory is stored, at least on Windows, is a matlab.settings file in the AppData folder. For example, mine is c:\users\username\AppData\Roaming\MathWorks\MATLAB\R2017b\matlab.settings with a key name of "InstallationFolder".
James Richard
James Richard 2022년 3월 20일
편집: James Richard 2022년 3월 20일
So what's the solution to change the add-ons directory directly?
We have this to change the hardware support package directory.
matlabshared.supportpkg.setSupportPackageRoot
But why don't we have something like this?
matlab.internal.setSettingsRoot

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 System Commands에 대해 자세히 알아보기

제품

질문:

aL
2017년 9월 29일

편집:

2022년 3월 20일

Community Treasure Hunt

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

Start Hunting!

Translated by