view m-toolbox/classes/@matrix/wrapper.m @ 46:ca0b8d4dcdb6 database-connection-manager

Fix
author Daniele Nicolodi <nicolodi@science.unitn.it>
date Tue, 06 Dec 2011 19:07:27 +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