Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Function name conflict. How to call a MATLAB toolbox function instead an user-defined function

Tags:

matlab

I have a problem that I could solve by changing my function's name. But I want to know if there's an option to call a MATLAB-defined function which has the same name of my user-defined function. By default, MATLAB always uses the user-defined function, but I want to use both in the same script. Any idea?

MATLABfuzzytoolbox::addrule(); userDefined::addrule()

like image 542
Vitrion Avatar asked Apr 14 '26 00:04

Vitrion


1 Answers

Matlab uses the first function with the specified name that shows up in the path, and there is no mechanism to call specifically one of the functions sharing the same name.

A good practice is to put your functions into packages. In this way you can name them with the same name than a built-in function, but the call is slightly different: for instance if you have a function addrule in the package Pack (i.e. a file addrule.m in a folder +Pack), you can call it with Pack.addrule, while the built-in addrule function is simply called by addrule.

Best,

like image 179
Ratbert Avatar answered Apr 16 '26 22:04

Ratbert



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!