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

조회 수: 31 (최근 30일)
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")

채택된 답변

Aishwarya Shukla
Aishwarya Shukla 2023년 3월 30일
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
Alexander
Alexander 2023년 3월 30일
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 2023년 4월 6일
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.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Introduction to Installation and Licensing에 대해 자세히 알아보기

제품


릴리스

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by