He01
He01

Reputation: 171

How to solve an internal function naming clashing?

I have been searching online for the answer of this question(including this site of course where I couldn't really find a satisfactory solution). My problem is the AddParameter function in class inputParser is conflicting with the function AddParameter in a Matlab toolbox function cgoptimoptions under package mbc:

which addParameter E:\study\compilers\MATLAB\R2012a\toolbox\mbc\mbcdata\@cgoptimoptions\addParameter.m % cgoptimoptions method

You see. I have been careful with the naming strategy of my own code. But this time it seems that it is the naming clashing between two internal functions (I call them internal functions because I assume that the AddParameter for inputParser is a built-in, and the one in the toolbox is also released by Mathworks as part of the IDE toolkits, so kinda also "official").

By looking into the function precedence and posts by others, I am aware that there are two things I can do to fix it: either change the names or manipulate the paths. Well, I don't like either of them because the first one will mess up the whole naming strategy clearly preferred by MathWorks and the second one does not really solve the problem if at some point I do need to use both of them.

So could you please give me some tips on how to systematically avoid this kind issues? It's been very frustrating for me.

Upvotes: 0

Views: 822

Answers (1)

nicolas
nicolas

Reputation: 3290

Instead of:

addParameter(p, 'normalize', normalize);

Use:

p.addParameter('normalize', normalize);

But it looks like addParameter is not part of the class inputParser. Use this to find the method to use:

methods(p)

It seems the class inputParser includes a method addParamValue but not addParameter.

Upvotes: 1

Related Questions