For example, in Java, there are 2 classes 'Date'. To resolve ambiguity in Java, we can specify clearly the class name to use / call by java.util.Date or java.sql.Date.

How can we handle this in Matlab? Let assume we will like to call Matlab's builtin function 'xlswrite' and custom-built function of the same name 'xlswrite' within the same .m program, how do we specify (in syntax) so that Matlab know which functions to reference to?

"Michael Teo" <mteo@empiricap.com> wrote in message <i6n7qv$i9e$1@fred.mathworks.com>...
> To all matlab experts,
>
> How to resolve conflict function call in Matlab?
>
> For example, in Java, there are 2 classes 'Date'. To resolve ambiguity in Java, we can specify clearly the class name to use / call by java.util.Date or java.sql.Date.
>
> How can we handle this in Matlab? Let assume we will like to call Matlab's builtin function 'xlswrite' and custom-built function of the same name 'xlswrite' within the same .m program, how do we specify (in syntax) so that Matlab know which functions to reference to?
>
> Thanks in advance for the helps!

There is no such thing in Matlab. You could use addpath() and rmpath() to select/hide the file in the specific path for ulterior call, but there is no way to do it on the fly (except fro script).

A better structure is to use OOP to define a method specific to the class.

"Michael Teo" <mteo@empiricap.com> wrote in message <i6n7qv$i9e$1@fred.mathworks.com>...
> To all matlab experts,
>
> How to resolve conflict function call in Matlab?
>
> For example, in Java, there are 2 classes 'Date'. To resolve ambiguity in Java, we can specify clearly the class name to use / call by java.util.Date or java.sql.Date.
>
> How can we handle this in Matlab? Let assume we will like to call Matlab's builtin function 'xlswrite' and custom-built function of the same name 'xlswrite' within the same .m program, how do we specify (in syntax) so that Matlab know which functions to reference to?
>
> Thanks in advance for the helps!

doc builtin

Put your custom function on the MATLAB path. When you call xlswrite it will call your custom function. When you want to call the builtin function, use builtin.

> There is no such thing in Matlab. You could use addpath() and rmpath() to select/hide the file in the specific path for ulterior call, but there is no way to do it on the fly (except fro script).
>
> A better structure is to use OOP to define a method specific to the class.
>
> Bruno

> Put your custom function on the MATLAB path. When you call xlswrite it will call your custom function. When you want to call the builtin function, use builtin.
>
> James Tursa

Thanks Bruno, James.

I guess the 'better' approach will be using OOP because 'builtin' can only differentiate between Matlab and a custom function. There will be an issue if there are 2 custom functions of the same name.

Matlab OOP is pretty new, there are limitation examples. Which books / sites will you recommend for Matlab OOP? Thanks.

> "Michael Teo" <mteo@empiricap.com> wrote in message
> <i6n7qv$i9e$1@fred.mathworks.com>...
> > To all matlab experts,
> >
> > How to resolve conflict function call in Matlab?
> >
> > For example, in Java, there are 2 classes 'Date'. To resolve ambiguity in
> > Java, we can specify clearly the class name to use / call by java.util.Date
> > or java.sql.Date.
> >
> > How can we handle this in Matlab? Let assume we will like to call Matlab's
> > builtin function 'xlswrite' and custom-built function of the same name
> > 'xlswrite' within the same .m program, how do we specify (in syntax) so
> > that Matlab know which functions to reference to?
> >
> > Thanks in advance for the helps!
>
> doc builtin
>
> Put your custom function on the MATLAB path. When you call xlswrite it will
> call your custom function. When you want to call the builtin function, use
> builtin.
>
> James Tursa

This won't work because xlswrite is not a built-in functions, it's an
m-file.

As an alternative to building a whole class just for this, the OP could
just put his xlswrite in a package directory, e.g.,

Hmmm ... you're right. I don't use builtin much and had assumed there wasn't a distinction between toolbox m-file functions and other MATLAB functions, but that isn't true. There isn't any mention of this in the doc for builtin. But I guess that means that the toolbox directories aren't treated as anything special with regards to the builtin function. Good to know. Thanks.