annotate 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 |
|
rev |
line source |
samer@39
|
1 % ge - collect outputs from function into cell array
|
samer@39
|
2 %
|
samer@39
|
3 % ge :: (A{:}=>B{1:N}), M:[N] -> (A{:}=>cell {B{1:M}}).
|
samer@39
|
4 %
|
samer@39
|
5 % f>=N is a function which takes the same arguments as f
|
samer@39
|
6 % but collects the first N return values into a cell array.
|
samer@39
|
7 % eg feval(@eig>=2,X) returns the eigenvalues and eigenvectors
|
samer@39
|
8 % of X in a two-element cell array.
|
samer@39
|
9
|
samer@38
|
10 function g=ge(f,nout)
|
samer@39
|
11 % if nargin<2, nout=nargout(f); end
|
samer@39
|
12 % if nout<0, error('function must have a definite number of outputs'); end
|
samer@38
|
13 if nargin(f)==1, g=@h1; else g=@hn; end
|
samer@38
|
14 function rets=h1(x), [rets{1:nout}]=f(x); end
|
samer@38
|
15 function rets=hn(varargin), [rets{1:nout}]=f(varargin{:}); end
|
samer@38
|
16 end
|