annotate 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 |
|
rev |
line source |
samer@39
|
1 % gt - select outputs from function
|
samer@39
|
2 %
|
samer@39
|
3 % gt :: (A{:}=>B{1:N}), I:[M]->[N]] -> (A{:}=>B{I}).
|
samer@39
|
4 %
|
samer@39
|
5 % f>[i,j,k...] is a function which takes the same arguments as f
|
samer@39
|
6 % but returns the ith,jth,kth etc return values from f as the 1st, 2nd, 3rd etc
|
samer@39
|
7 % return values.
|
samer@39
|
8 % eg feval(@eig>2,X) returns the eigenvectors of X.
|
samer@39
|
9
|
samer@38
|
10 function g=gt(f,I,nin)
|
samer@38
|
11 if nargin<3, nin=nargin(f); end
|
samer@38
|
12 nout=length(I); MI=max(I);
|
samer@38
|
13 fns = { @q11, @q1n; @qn1, @qnn };
|
samer@38
|
14 g=fns{acount(nin,1),acount(nout,1)};
|
samer@38
|
15
|
samer@38
|
16 function y=q11(x), [rets{1:MI}]=f(x); y=rets{I}; end
|
samer@38
|
17 function y=qn1(varargin), [rets{1:MI}]=f(varargin{:}); y=rets{I}; end
|
samer@38
|
18 function varargout=q1n(x), [rets{1:MI}]=f(x); varargout=rets(I); end
|
samer@38
|
19 function varargout=qnn(varargin), [rets{1:MI}]=f(varargin{:}); varargout=rets(I); end
|
samer@38
|
20 end
|
samer@38
|
21
|