Mercurial > hg > ishara
view general/funutils/@function_handle/ge.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
% ge - collect outputs from function into cell array % % ge :: (A{:}=>B{1:N}), M:[N] -> (A{:}=>cell {B{1:M}}). % % f>=N is a function which takes the same arguments as f % but collects the first N return values into a cell array. % eg feval(@eig>=2,X) returns the eigenvalues and eigenvectors % of X in a two-element cell array. function g=ge(f,nout) % if nargin<2, nout=nargout(f); end % if nout<0, error('function must have a definite number of outputs'); end if nargin(f)==1, g=@h1; else g=@hn; end function rets=h1(x), [rets{1:nout}]=f(x); end function rets=hn(varargin), [rets{1:nout}]=f(varargin{:}); end end