matrix multiplication
显示 更早的评论
Assume we have the following matrix A = [ 1 2; 3 4; 5 6]; and we want to do the following multiplication
[ A(:,1)*A(:,1)';A(:,2)*A(:,2)'] without loop. So the result should be like this B =
1 3 5
3 9 15
5 15 25
4 8 12
8 16 24
12 24 36
Could you please help me with this problem.
Thanks
1 个评论
James Tursa
2012-1-28
Ummm ... you already did. I presume you really have a more general question in mind? Like a larger size variable? Or ...?
采纳的回答
更多回答(1 个)
Andrei Bobrov
2012-1-28
B = reshape(bsxfun(@times,permute(A,[1 3 2]),permute(A,[3 1 2])),size(A,1),[]).'
类别
在 帮助中心 和 File Exchange 中查找有关 Creating and Concatenating Matrices 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!