view m-toolbox/classes/@matrix/wrapper.m @ 23:a71a40911c27 database-connection-manager

Update check for repository connection parameter in constructors
author Daniele Nicolodi <nicolodi@science.unitn.it>
date Mon, 05 Dec 2011 16:20:06 +0100
parents f0afece42f48
children
line wrap: on
line source

% 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