How to use the dot product within a loop to multiply a series of rows?!
Show older comments
I currently have two matrices.
- V = (1*3) matrix
- coordNORMALS = (18766*3) matrix.
I would like to take the dot product of the two such that:
- C = dot ( V, coordNORMALS)
I understand that to take the dot product the size of the two matrices must be equal, however I would like to find C for each row, i.e get 18766 values of C
C = dot ( V, coordNORMALS (1 , : )) all the way to C = dot ( V, coordNORMALS ( end , : ))
I have tried to use a loop in the following format but end up in an infinite loop:
for i=1:length(coordNORMALS)
C(i) = dot(V,coordNORMALS(i,:))
end
end
If anyone knows how to help, please reply
Many Thanks Josh
Accepted Answer
More Answers (1)
James Tursa
on 25 Mar 2014
A direct matrix multiply is likely to be faster than using dot. E.g., assuming the variables are real:
C = coordNORMALS * V.';
Categories
Find more on Loops and Conditional Statements in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!