Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Installing add-ons without display

Tags:

matlab

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?

like image 551
Jonathan H Avatar asked Sep 23 '15 13:09

Jonathan H


People also ask

How do I show the add-ins tab in Excel?

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.

How do I install add-ons?

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.


2 Answers

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:

root folder

If we examine the contents of fsroot, we see that it's the folder of data packaged into the toolbox:

folder contents

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');
like image 130
sco1 Avatar answered Oct 04 '22 19:10

sco1


As of R2016a, there is a MATLAB API to install them:

matlab.addons.toolbox.installToolbox('mytoolbox.mltbx')
like image 36
John Avatar answered Oct 04 '22 20:10

John