installed toolbox is not added to Matlab path

I created a toolbox called Alexandria. This toolbox is now available on File Exchange (https://fr.mathworks.com/matlabcentral/fileexchange/108834-alexandria). To test that everything is fine, I downloaded and installed my own toolbox on my Matlab. The installation goes fine, but then I cannot use anything from my toolbox. For instance, the toolbox has a class for Bayesian linear regression called SimpleBayesianRegression. But when I use the command
lr = SimpleBayesianRegression(y,X)
I receive an error:
So it seems that in order to use the toolbox, I first need to add the toolbox root folder and its subfolders to the Matlab path. But aren't toolboxes precisely supposed to take care of all the path management at installation, so that the user doesn't have to do that himself? Or I am missing something, and it is normal that the path has to be added manually after the install?
Thanks a lot for any reply.

1 commentaire

As an additional insight: when I use the Set Path panel, the path to the toolbox is present on the Matlab search path, as can be seen at the bottom of the list:
So I really cannot make sense of the error message obtained when trying to use the toolbox.

Connectez-vous pour commenter.

 Réponse acceptée

But /root/MATLAB Add-Ons/Toolboxes/alexandria/alexandria is not on the path and neither is /root/MATLAB Add-Ons/Toolboxes/alexandria/alexandria/linearregression
I get the impression that the intent was that the functions would only be used from inside the graphics interface.
You can work around the problem by using
addpath(genpath('/root/MATLAB Add-Ons/Toolboxes/alexandria'))

3 commentaires

Romain Legrand
Romain Legrand le 26 Mar 2022
Modifié(e) : Romain Legrand le 26 Mar 2022
Dear Walter,
thank you very much for your answer. The intent of the toolbox is that there are several entry points to the toolbox. One such entry point could indeed be the GUI, but for that I plan to have the user run an external script that would call the GUI classes inside the toolbox.
The main intent with the toolbox is that the user can call the classes "on the fly". As said in my original post, I would for instance expect the user to be capable of typing directly in the Matlab console the command
lr = SimpleBayesianRegression(y,X)
and the class would be called correctly. I would expect to be capable of doing this without having to add some folders to the path.
You mention that /root/MATLAB Add-Ons/Toolboxes/alexandria/alexandria is not on the path and neither is /root/MATLAB Add-Ons/Toolboxes/alexandria/alexandria/linearregression. But precisely, I expected that installing a toolbox would add not only the root folder of the toolbox to the path, but also all the subfolders. If that is not the case, then the interest of creating a toolbox seems limited at best.
So, to make sure that I understand correctly:
  • installing a toolbox only adds the toolbox root folder to the path, not its subfolders. If any functionality (class/function) from a subfolder is used, this specific directory must first be added to the path. Is that correct?
  • If that is correct, is there a way to make sure the toolbox is installed at once with all the subfolders added to the path? That seems necessary in my case as my classes are highly interdepedent, and so one class needs access to all others.
Thank you very much for your help :)
My understanding is that each toolbox can have an installation script provided by the person who wrote the toolbox, and that script would be responsible for any path generation beyond the top level.
Thanks again for the useful comments. In the end, it seems the easiest way to solve my issue consists in setting the path manually from the Matlab panel. Use set path -> Add with subfolders, then select the root folder of the toolbox (that has normally been added to the list of existing paths at installation) -> Save (which keeps the path for future sessions).
Once this is done, all the subfolders of the toolbox have been added permanently to the path, and one can call any function/class without further ado.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

Community Treasure Hunt

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

Start Hunting!

Translated by