matrixfunction

by

 

28 Feb 2009 (Updated )

summary

matrixfunrr(hFunction,A,B)
function Y = matrixfunrr(hFunction,A,B)
% matrixfunrr
%   Y = matrixfunrr(hFunction,A,B)
%
%   Invokes hFunction on the rows of matrices A and B. 
%   hFunction is a function handle that accepts two vectors.
%   hFunction is invoked aRows*bRows times.
%   Y is a cell matrix of size([aRows bRows]). 
%
%   Example
%       A = [1 2 3; 4 5 6; 7 8 9]
%       Y = matrixfunrr(@dot,A,A);         % Simple example, same as A*A'
%       Y = [14]    [ 32]    [ 50]
%           [32]    [ 77]    [122]
%           [50]    [122]    [194]
%
%   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
nB = size(B,1);                             % Matrix size
Y = cell([nA nB]);                          % Prefine loop variable
for i = 1:nA                              	% Loop through each row
    for j = 1:nB                            % Loop through each row
        Y{i,j} = hFunction(A(i,:),B(j,:));	% Invoke function
    end
end
end

Contact us