MATLAB: Projection matrix equation equivalent

matrixmultiplication

Hello,
I am relative new to matlab and would sincerely appreciate some help in understanding the logic of calculations that use the following notation.
A = B(i,:) * B';
I am familiar enough with matlab to understand most of its syntax so my question isn't about understanding what this expression is saying but rather the operation behind it.
For example if B = rand(10,3) what sequence of operations would produce the equivalent result for A to the above?
(I would like to unpack this so that I can build an equivalent function in C)

Best Answer

To reproduce in C you'd need for loops. I believe this explains it:
B = rand(10,3);
i = 4; % Whatever....
% Method 1:
A = B(i,:) * B'
[rows, columns] = size(B)
% Method 2:
A2 = zeros(1, rows);
for row = 1 : rows
for col = 1 : columns
A2(row) = A2(row) + B(i, col) * B(row, col);
end
end
A2
% Check to make sure they're the same
% Will show 1 if they're equal.
isequal(A, A2)