How to disable a toolbox

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).

 Accepted Answer

Matt J
Matt J on 25 Jun 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 Comments

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.
Then perhaps a solution is to put the functions in a package directory and import them. Then all those names rise to level 2.
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 on 5 Jul 2020
Edited: Matt J on 5 Jul 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
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.
Ok, thanks a lot!
You're welcome, but please Accept-click the answer if you consider your question addressed.

Sign in to comment.

More Answers (1)

Image Analyst
Image Analyst on 5 Jul 2020
Edited: Image Analyst on 5 Jul 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.

Categories

Products

Release

R2019b

Asked:

on 25 Jun 2020

Edited:

on 5 Jul 2020

Community Treasure Hunt

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

Start Hunting!