How to install required add-ons when using matlab.addons.install

31 views (last 30 days)
When installing an mltbx that has required addons by double clicking on it from the "Current Folder" panel the IDE will tell me about any additional required addons (toolboxes) that needs to be installed and install them as part of the interaction. If the toolbox is already present and has multiple versions available it will change the enabled version to the one that the mltbx requires during install.
I noticed that neither of these things happen if I install a toolbox using the matlab addon or toolbox install apis. I was wondering if there are other APIs that I can use to query an mltbx for it's "Required Add-ons" dependencies as part of an install from the command window (or other non GUI environment) to then pass to additional API install calls, or another way to achieve parity with the mltbx GUI installer functionality in a script environment.
I will note that calling open runs the dialog, but want to confirm this is intended (as mltbx is not on the doc page), and I need to test the behavior in a non interactive environment to see if it will automatically manage the install, or fail since there can be a confirmation dialog.
open("<name>.mltbx")

Accepted Answer

Aishwarya Shukla
Aishwarya Shukla on 30 Mar 2023
Yes, you can query an mltbx for its "Required Add-ons" dependencies using MATLAB's matlab.addons.toolbox.toolboxVersion function. This function returns information about a toolbox version, including its required add-ons.
Here's an example of how you can use this function to get the required add-ons for a toolbox:
tbxInfo = matlab.addons.toolbox.toolboxVersion('<name>');
requiredAddons = tbxInfo.RequiredAddons;
This will return a cell array of required add-ons for the specified toolbox. You can then use this information to install the required add-ons using the matlab.addons.toolbox.installToolbox function:
for i = 1:length(requiredAddons)
addonName = requiredAddons{i};
matlab.addons.toolbox.installToolbox(addonName);
end
This will install each required add-on in turn. Note that you may need to provide additional arguments to the installToolbox function to specify installation options (such as installation directory or version) depending on your specific use case.
Regarding your question about calling open in a non-interactive environment, it's possible that this may not work as expected if there are confirmation dialogs or other interactive prompts involved in the installation process. In this case, you may need to use the matlab.addons.toolbox.installToolbox function or other installation APIs to ensure a fully automated installation process.
  5 Comments
Alexander
Alexander on 30 Mar 2023
Thanks again Aishwarya. I hadn't picked up from the docs that I could pass a struct to installToolbox, but I see that using help now. This is all really helpful.
Aishwarya Shukla
Aishwarya Shukla on 6 Apr 2023
Hi @Alexander, I apologise for a overlook, the command:
tbxInfo = matlab.addons.toolbox.toolboxVersion('<name>');
Only returns the version as a char and actually currently there is no documented function to get the dependency information.

Sign in to comment.

More Answers (0)

Categories

Find more on Introduction to Installation and Licensing in Help Center and File Exchange

Products


Release

R2019a

Community Treasure Hunt

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

Start Hunting!