function whose arguments contains a function with possibly a variable number of outputs
1 次查看(过去 30 天)
显示 更早的评论
I am writing a class which calls matrix and vector matlab functions adding some stuff to obtain an approximation of the number of significant bits.
For example with A=hilb(10) whose condition number is about 1e13 if I compute det(A) A beeing an object of my class I obtain 2.1640e-53 the number of displayed digits is automatically limited to the expected correct ones. To achive this I overload matlab function as shown below:
%%%%
methods
function C=mldivide(A,B), C=rfpa.OP(@mldivide,A,B);end
function d=det(A), d=rfpa.OP(@det,A);end
function B=inv(A), B=rfpa.OP(@inv,A);end
function c=cond(A), c=rfpa.OP(@cond,A);end
......
%%%
OP is a static method :
function xr=OP(fun,varargin)
x1=fun(varargin{:});
xr=zeros(size(x1),'rfpa');
.....
This works fine but I have not found how to do, when function has a variable number of outputs as QR SVD for example.
Is it possible to implement something like
function varargout=OP(fun,varargin)
[varargout{1:nargout}]=fun(varargin{:});
.....
My current solution is to have specific wrapper for QR SVD etc... which is no intellectually satisfactory.
Any help will be welcome.
Alain
0 个评论
采纳的回答
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Logical 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!