如何获取覆盖的内置函数的句​​柄? [英] How to get a handle to an overriden built-in function?

查看:73
本文介绍了如何获取覆盖的内置函数的句​​柄?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的Matlab路径上,有一个自定义的zeros函数.我想将内置zeros的句柄存储在变量中.我该怎么办?

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?

考虑了@(varargin)builtin('zeros',varargin{:}),但是由于字符串比较,这可能会减慢操作的速度.

Thought about @(varargin)builtin('zeros',varargin{:}), but this would probably slow down the operation due to the string comparison.

此外,我注意到可以将diag称为@numel\diag,但这似乎不适用于其他内置函数(尤其是zeros).

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).

推荐答案

好吧,这不能给您确切的答案,但是可以解决问题:

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:如何调用带阴影的函数

在上一篇文章中:

偶然发现了这个问题,并找到了以下解决方案: 例如,我的libsvm工具箱遮盖了matlab svmtrain:

Just stumbled upon this problem and found the following solution: For example, I have matlab svmtrain shadowed by libsvm toolbox:

哪个svmtrain -all

which svmtrain -all

C:\ Projects \ Ichilov \ Misc \ MVPA \ libsvm-mat-3.0-1 \ svmtrain.mexw64

C:\Projects\Ichilov\Misc\MVPA\libsvm-mat-3.0-1\svmtrain.mexw64

C:\ Program Files \ MATLAB \ R2009b \ toolbox \ bioinfo \ biolearning \ svmtrain.m %阴影

C:\Program Files\MATLAB\R2009b\toolbox\bioinfo\biolearning\svmtrain.m % Shadowed

但是我可以使用str2func访问原始功能:

But I can access the original function by using str2func:

org_svmtrain = str2func([matlabroot'\ toolbox \ bioinfo \ biolearning \ svmtrain'])

org_svmtrain = str2func([matlabroot '\toolbox\bioinfo\biolearning\svmtrain'])

然后简单地调用:

org_svmtrain(培训,组名)

org_svmtrain(training, groupnames)

这篇关于如何获取覆盖的内置函数的句​​柄?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆