There are more and more packages on Matlab Central that are shared in the form of add-ons or custom toolboxes (extension .mltbx
).
I'm using such toolboxes and when on my desktop I can simply install them by clicking on them. However my code is eventually deployed on a cluster, where none of the nodes has these toolboxes installed and none of the Matlab instance is run with display.
How can I install add-ons programmatically?
Click the File tab, click Options, and then click the Add-Ins category. In the Manage box, click Excel Add-ins, and then click Go. The Add-Ins dialog box appears. In the Add-Ins available box, select the check box next to the add-in that you want to activate, and then click OK.
Go to your the Zipped AddOn file and open it. Select all the files in the Zipped File, and drag and drop the AddOn's folders from the zip into your _retail_\Interface\AddOns folder. Make sure you do not drop them into a folder of an AddOn already installed.
Poking around MATLAB's subroutines I couldn't figure out an obvious way to handle this programmatically without at least some user input.
That being said, the *.mltbx
package is really just a *.zip
file, which we can access directly inside MATLAB. To illustrate this, I've created a quick toolbox using my code prototyping folder, testcode-matlab.mltbx
.
If you extract the contents of this file using unzip
: unzip('testcode-matlab.mltbx', 'temp');
you should be left with something like the following:
If we examine the contents of fsroot
, we see that it's the folder of data packaged into the toolbox:
So we can take this folder, move it to where we want using something like copyfile
, and then add it to the MATLAB path using addpath
:
copyfile('.\temp\fsroot', '.\mytoolboxes\testtoolbox');
addpath('.\mytoolboxes\testtoolbox');
As of R2016a, there is a MATLAB API to install them:
matlab.addons.toolbox.installToolbox('mytoolbox.mltbx')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With