Vectorization of matrices multiplication
3 次查看(过去 30 天)
显示 更早的评论
Hi,
i have some trouble finding out how to vectorize the following loop:
for k = 1:PointsLength
h(k,1) = transpose(PointsA(:,k) - PointsB(:,k))*normals(:,k);
end
The first thing that comes into my mind is doing this:
all the matrices have 3 x n dimensions and i want h to be 1 x n vector
k = 1:PointsLength
h(:) = transpose(PointsA(:,k) - PointsB(:,k))*normals(:,k);
but its obviously it's not the same thing since im trying to achieve row column multiplication only in pairs ( just k_th row times k_th column, without k_th row times other columns), and thus gives error cause he expects h to be n x n.
Any ideas? Thank you in advance.
采纳的回答
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Matrix Indexing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!