function varargout = rowfun(fn, varargin) %ROWFUN apply function to each row of array returning array of answers % % results = rowfun(fn, A) % Apply function fn to each row of A and return each answer % as a row of results. Note that answers must stack above each other. % % [a, b, ...] = rowfun(fn, A) % Apply function fn to each row of A. Output a is an array containing % all of the first outputs. Likewise b contains all of the second outputs. % % ... = rowfun(fn, A, B, ...) % Now fn takes multiple arguments, taking a row from each of the input % arrays A, B, ... % % See also: colfun, rowmap, colmap % Iain Murray, November 2007 varargout = cell(1, max(1, nargout)); [varargout{:}] = dimfun(fn, 2, varargin{:});