Mercurial > hg > ltpda
diff m-toolbox/classes/@matrix/wrapper.m @ 0:f0afece42f48
Import.
author | Daniele Nicolodi <nicolodi@science.unitn.it> |
---|---|
date | Wed, 23 Nov 2011 19:22:13 +0100 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/m-toolbox/classes/@matrix/wrapper.m Wed Nov 23 19:22:13 2011 +0100 @@ -0,0 +1,42 @@ +% WRAPPER applies the given method to each object in the matrix. +% +% CALL +% out = wrapper(objs, pl, info, inputnames, methodName) +% +% $Id: wrapper.m,v 1.1 2011/08/23 13:50:36 hewitson Exp $ +% +function varargout = wrapper(varargin) + + % Collect all matrix objects and plists + objs = varargin{1}; + pl = varargin{2}; + info = varargin{3}; + inputnames = varargin{4}; + methodName = varargin{5}; + + % Merge with default plist: done in the ao method + + % deep copy + mat = copy(objs,1); + + n = numel(mat); + + % loop over number of matrices + for ii = 1:n + % get size of object + [rw,cl] = size(mat(ii).objs); + + % loop over raws and columns + for kk = 1:rw + for jj = 1:cl + mat(ii).objs(kk,jj) = feval(methodName, mat(ii).objs(kk,jj),pl); + end + end + mat(ii).addHistory(info, pl, {inputnames(ii)}, [mat(ii).hist]); + end + + varargout{1} = mat; + + +end +