This question already has an answer here:
- How to unhide an overriden function? 1 answer
On my Matlab path there's a custom zeros
function. I want to store a handle to the built-in zeros
in a variable. How can I do that?
Thought about @(varargin)builtin('zeros',varargin{:})
, but this would probably slow down the operation due to the string comparison.
Also, I've noticed that it's possible to refer to diag
as @numel\diag
, but this doesn't seem to work with other built-in functions (zeros
in particular).
Suggestion #1
Suggestion #2
Put these three lines into your startup file:
Suggestion #3
It's definitely a dangerous idea to reuse the name of a built-in function. It ruins the readability of your scripts, making them much more difficult to maintain. So if you have control over the custom
zeros
function, then rename it to something else. Use a name which describes how the custom version is different from the built-in one (for example, call itfastZeros
if it's faster).Well, this doesn't give you an exact answer to your question, but it could solve the problem:
I think this seems to be a good solution:
matlabcentral: How to call a shadowed function
Withn the last post: