How can I disable a particular toolbox? I have my own code, in which I am using a function 'diffusion', which is preceded, possibly by a function from financial toolbox. Running it on my home PC terminates successfully, but on HP cluster it throws an error, confusing the two functions (saying e.g. that I give too many input arguments).

 Réponse acceptée

Matt J
Matt J le 25 Juin 2020

0 votes

Add all your code to the top of the Matlab path using addpath
Then, Matlab will see your version of diffusion first, and use that.

7 commentaires

Steven Lord
Steven Lord le 25 Juin 2020
It's not quite that simple. The diffusion in Financial Toolbox is a class in a directory @diffusion and in the function precedence order that puts it at level 8. Functions in the current directory are at level 10 and those on the path are at level 11.
Matt J
Matt J le 27 Juin 2020
Then perhaps a solution is to put the functions in a package directory and import them. Then all those names rise to level 2.
Gus C
Gus C le 4 Juil 2020
Hello, thanks for answering so swiftly!
Unfortunately I don't have access to Matlab installation folder on this computer, I cannot make any changes like modify Matlab subfolders. However, I have already tried the version with importing the package folder in which I have placed my function and it worked! So, many thanks to Matt J!
Just one more question: this does not seem to work when I just import diffusion on the level of my code's main file, it has to be imported within a function which calls diffusion (and it is being repeatedly called thus I need to import the package in every iteration). Is there a way around it?
Matt J
Matt J le 5 Juil 2020
Modifié(e) : Matt J le 5 Juil 2020
Unfortunately I don't have access to Matlab installation folder on this computer, I cannot make any changes like modify Matlab subfolders.
And well you shouldn't! You misunderstood if you thought one of us was telling you to do that.
it has to be imported within a function which calls diffusion (and it is being repeatedly called thus I need to import the package in every iteration). Is there a way around it?
Not that I can see, but the overhead of importing iteratively should be tiny and the simple test below seems to confirm this. My version of +package.diffusion does nothing, so the 0.008 sec. should be almost entirely due to the 1000 imports.
>> tic; for i=1:1000, test; end; toc;
Elapsed time is 0.008674 seconds.
function test
import package.diffusion
diffusion();
end
Matt J
Matt J le 5 Juil 2020
You could also consider making your version of diffusion a private function,
This way, no import statements would be necessary, but note that your diffusion() would then be visible only to functions in the private/ folder and its parent.
Gus C
Gus C le 5 Juil 2020
Ok, thanks a lot!
Matt J
Matt J le 5 Juil 2020
You're welcome, but please Accept-click the answer if you consider your question addressed.

Connectez-vous pour commenter.

Plus de réponses (1)

Image Analyst
Image Analyst le 5 Juil 2020
Modifié(e) : Image Analyst le 5 Juil 2020

2 votes

To disable an entire toolbox -- ALL of it's functions -- you can uninstall it from the Add-On Manager (Home tab of Toolbar -> Add-ons -> financial toolbox -> three dots -> Uninstall). I don't think it actually deletes the files. It's not quick, like a one-liner you can do in your code. Then to turn it back on, you again use the Add-on Manager to re-enable it.

Catégories

En savoir plus sur Startup and Shutdown dans Centre d'aide et File Exchange

Produits

Version

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by