Projection matrix equation equivalent?

5 views (last 30 days)
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)

Accepted Answer

Image Analyst
Image Analyst on 21 Oct 2017
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)
  1 Comment
tree317
tree317 on 21 Oct 2017
Image Analyst,
Very very helpful - a sincere thanks!

Sign in to comment.

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!