MATLAB: Is there a way to use the own function file for a Matlab function

functions

Dear Matlab users,
I would like to know if it is possible to substitute a Matlab function with my own .m file? Why I want do to this: I process a lot of imaging data and I seem to run out of Image_Toolbox licenses sooner than Matlab licenses. The processing pipeline seems to use only `imerode` function from the toolbox, so I wrote my own function `own_imerode.m`. Luckily, it is quite straight-forward. However, I would like not to replace `imerode` with `own_imerode` throughout the code for two reasons – backward compatibility and hassle of going through the code. Instead, I was wondering if it is possible to tell Matlab to somehow use `own_imerode` when `imerode` is called, like an alias in a bash shell? I guess, one way would be to call my function also `imerode` and place the path to it on top of the list. Is there another way?
Best, Renat.

Best Answer

Renat, the root cause appears to be a lack of purchased toolboxes. Also you seem to process a lot of images. So I suggest you also look for accessing a cluster. You might have a MATLAB Distributed Computing Server license at your institution.
Beside that, I would not fiddle with the installation. You may want to a simple IF THEN ELSE statement at the beginning that looks for the toolbox being available and if yes use it and if not the alternative way. Command to use could be:
license('test','Image_Toolbox')