A while ago I have written a FEX submission that extends the capabilities of |find| to also work for 3D and up: <https://www.mathworks.com/matlabcentral/fileexchange/64383-findnd |findND|> (e.g. a syntax like |[x,y,z,val]=findND(A)|).
I would like to be able to shadow the built-in function, so I have the option of simply using |[x,y,z,val]=find(A)| in my code. My function would then use the code from <https://www.mathworks.com/matlabcentral/answers/149059-how-do-i-invoke-a-shadowed-core-matlab-function-not-built-in-from-an-overloaded-function-of-same this previous question> to get a handle to the built-in function, so my function catches the call to |find| and does its thing if it needs to. Based on <https://www.mathworks.com/matlabcentral/answers/90268-shadowing-built-in-functions this> question, I would have thought that it would be relatively easy to do this: just ignore the warning.
However, when I try this, it doesn’t work: Matlab still calls the built-in function. |list = which(‘find’, ‘-all’)| shows my function as the first entry (for R2017b and R2012b).
It makes sense that Matlab would use the built-in, as that is the <https://www.mathworks.com/help/matlab/matlab_prog/function-precedence-order.html function precedence order>, but in that case I don’t understand why |which| would think that the local function would take precedence.
Is there a way to do this (preferably without requiring the end-user to jump through many hoops), or should I give up and just use my function under its own name?A while ago I have written a FEX submission that extends the capabilities of |find| to also work for 3D and up: <https://www.mathworks.com/matlabcentral/fileexchange/64383-findnd |findND|> (e.g. a syntax like |[x,y,z,val]=findND(A)|).
I would like to be able to shadow the built-in function, so I have the option of simply using |[x,y,z,val]=find(A)| in my code. My function would then use the code from <https://www.mathworks.com/matlabcentral/answers/149059-how-do-i-invoke-a-shadowed-core-matlab-function-not-built-in-from-an-overloaded-function-of-same this previous question> to get a handle to the built-in function, so my function catches the call to |find| and does its thing if it needs to. Based on <https://www.mathworks.com/matlabcentral/answers/90268-shadowing-built-in-functions this> question, I would have thought that it would be relatively easy to do this: just ignore the warning.
However, when I try this, it doesn’t work: Matlab still calls the built-in function. |list = which(‘find’, ‘-all’)| shows my function as the first entry (for R2017b and R2012b).
It makes sense that Matlab would use the built-in, as that is the <https://www.mathworks.com/help/matlab/matlab_prog/function-precedence-order.html function precedence order>, but in that case I don’t understand why |which| would think that the local function would take precedence.
Is there a way to do this (preferably without requiring the end-user to jump through many hoops), or should I give up and just use my function under its own name? A while ago I have written a FEX submission that extends the capabilities of |find| to also work for 3D and up: <https://www.mathworks.com/matlabcentral/fileexchange/64383-findnd |findND|> (e.g. a syntax like |[x,y,z,val]=findND(A)|).
I would like to be able to shadow the built-in function, so I have the option of simply using |[x,y,z,val]=find(A)| in my code. My function would then use the code from <https://www.mathworks.com/matlabcentral/answers/149059-how-do-i-invoke-a-shadowed-core-matlab-function-not-built-in-from-an-overloaded-function-of-same this previous question> to get a handle to the built-in function, so my function catches the call to |find| and does its thing if it needs to. Based on <https://www.mathworks.com/matlabcentral/answers/90268-shadowing-built-in-functions this> question, I would have thought that it would be relatively easy to do this: just ignore the warning.
However, when I try this, it doesn’t work: Matlab still calls the built-in function. |list = which(‘find’, ‘-all’)| shows my function as the first entry (for R2017b and R2012b).
It makes sense that Matlab would use the built-in, as that is the <https://www.mathworks.com/help/matlab/matlab_prog/function-precedence-order.html function precedence order>, but in that case I don’t understand why |which| would think that the local function would take precedence.
Is there a way to do this (preferably without requiring the end-user to jump through many hoops), or should I give up and just use my function under its own name? shadow built-in MATLAB Answers — New Questions
