function whose arguments contains a function with possibly a variable number of outputs
1 view (last 30 days)
Show older comments
Alain Barraud
on 31 Aug 2021
Commented: Alain Barraud
on 1 Sep 2021
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 Comments
Accepted Answer
More Answers (0)
See Also
Categories
Find more on Logical in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!