function whose arguments contains a function with possibly a variable number of outputs
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Alain Barraud
am 31 Aug. 2021
Kommentiert: Alain Barraud
am 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 Kommentare
Akzeptierte Antwort
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Logical finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!