How to call a shadowed function in Octave?

人走茶凉 提交于 2020-01-15 02:54:49

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!