Mercurial > hg > ishara
view general/funutils/@function_handle/gt.m @ 61:eff6bddf82e3 tip
Finally implemented perceptual brightness thing.
author | samer |
---|---|
date | Sun, 11 Oct 2015 10:20:42 +0100 |
parents | c388f1c70669 |
children |
line wrap: on
line source
% gt - select outputs from function % % gt :: (A{:}=>B{1:N}), I:[M]->[N]] -> (A{:}=>B{I}). % % f>[i,j,k...] is a function which takes the same arguments as f % but returns the ith,jth,kth etc return values from f as the 1st, 2nd, 3rd etc % return values. % eg feval(@eig>2,X) returns the eigenvectors of X. function g=gt(f,I,nin) if nargin<3, nin=nargin(f); end nout=length(I); MI=max(I); fns = { @q11, @q1n; @qn1, @qnn }; g=fns{acount(nin,1),acount(nout,1)}; function y=q11(x), [rets{1:MI}]=f(x); y=rets{I}; end function y=qn1(varargin), [rets{1:MI}]=f(varargin{:}); y=rets{I}; end function varargout=q1n(x), [rets{1:MI}]=f(x); varargout=rets(I); end function varargout=qnn(varargin), [rets{1:MI}]=f(varargin{:}); varargout=rets(I); end end