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

 채택된 답변

Matt J
Matt J 2020년 6월 25일

0 개 추천

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

Steven Lord
Steven Lord 2020년 6월 25일
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 2020년 6월 27일
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 2020년 7월 4일
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 2020년 7월 5일
편집: Matt J 2020년 7월 5일
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 2020년 7월 5일
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 2020년 7월 5일
Ok, thanks a lot!
Matt J
Matt J 2020년 7월 5일
You're welcome, but please Accept-click the answer if you consider your question addressed.

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Image Analyst
Image Analyst 2020년 7월 5일
편집: Image Analyst 2020년 7월 5일

2 개 추천

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.

카테고리

도움말 센터File Exchange에서 Startup and Shutdown에 대해 자세히 알아보기

제품

릴리스

R2019b

질문:

2020년 6월 25일

편집:

2020년 7월 5일

Community Treasure Hunt

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

Start Hunting!

Translated by