samer@4: function cfn=bindat(fn,varargin) samer@4: % bindat - Create function with bound arguments at given positions samer@4: % samer@4: % BINDAT(fn,positions,arguments) samer@4: % If fn is an ordinary function handle, the parameters a1, a2 etc samer@4: % are bound at the positions given samer@4: % samer@4: % If fn is a closure as returned by FUNC, BIND, or PERM, samer@4: % the given parameters are bound to the specified slots of the function. samer@4: % samer@4: % Eg, a function which divides a value by 4 can be given as samer@4: % samer@4: % quarter = bindat(@rdivide,2,2); samer@4: % quarter(8) samer@4: % ans = 2 samer@4: samer@4: if ischar(fn), fn=str2func(fn); end samer@4: if ~isa(fn,'func'), fn=func(fn); end samer@4: cfn=bindat(fn,varargin{:});