matrixfunction

by

 

28 Feb 2009 (Updated )

summary

matrixfunir(hFunction,A,B)
function Y = matrixfunir(hFunction,A,B)
% matrixfunir
%   Y = matrixfunir(hFunction,A,B)
%
%   Invokes hFunction on the rows of matrix A. 
%   hFunction is a function handle that accepts two vectors.
%   hFunction is invoked aRows times.
%   Y is a cell matrix of size([aRows 1]). 
%
%   Example
%       A = magic(3);
%       Y = matrixfunir(@sum,A);         
%       Y = [15]
%           [15]
%           [15]
%
%   See also
%       matrixfun matrixfunrr matrixfunrc matrixfuncc matrixfuncr matrixfunt
%       matrixfunn matrixfunrrn matrixfunrcn matrixfunccn matrixfuncrn matrixfuntn
%       matrixfuni matrixfunir matrixfunic
%

%% Author Information
%   Pierce Brady
%   Smart Systems Integration Group
%	Cork Institute of Technology
% 

%%
nA = size(A,1);                 % Matrix size
Y = cell([nA 1]);               % Prefine loop variable
for i = 1:nA                    % Loop through each row
    Y{i} = hFunction(A(i,:));   % Invoke function
end
end

Contact us