问题
I want to modify the behaviour of the vpa
function. For that I define my own function called vpa
that calls the original vpa
function and then does some more stuff.
To call the original function from within my modified function I use
y = builtin('vpa', varargin{:});
where varargin
is a cell array of the function inputs, as usual.
The problem is that the above produces a different result than calling the original vpa
function.
Minimal example, run on Octave 4.2.2:
>> vpa([4 5], 20)
ans = (sym) [4.0 5.0] (1x2 matrix)
>> builtin('vpa',[4 5], 20)
ans = (sym) 4.0000000000000000000
The same happens with disp
for symbolic arguments:
>> x = sym(8);
>> disp(x)
8
>> builtin('disp', x)
<class sym>
Why is the output different? Doesn't builtin
really call the original function? If so, how can I call the original function?
Related question and answer.
来源:https://stackoverflow.com/questions/58727452/how-to-call-a-shadowed-function-in-octave