Element-wise multiplication where 'elements' are matrices and vectors

3 次查看(过去 30 天)
I have a 'stack' of K n-by-1 vectors x that I would like to multiply by a 'stack' of K n-by-n vectors A, to form a 'stack' of K n-by-1 output vectors y such that
y((k-1)*n+1:k*n) = A((k-1)*n+1:k*n, 1:n) * x((k-1)*n+1:k*n)
where k runs from 1 to K.
I would like to do this without looping through k. I thought of using the 'blockproc' function, but it only seems to be able to blockify one argument, and I need to blockify two (both A and x). I thought of trying to turn A into a Kn-by-Kn block diagonal matrix, then multiplying it directly by x (which is Kn-by-1), but K could be quite large and there does not seem to be a sparse version of blkdiag. Finally, bsxfun does not seem to fit this problem.
Any ideas?

回答(1 个)

Bruno Luong
Bruno Luong 2011-2-20

类别

Help CenterFile Exchange 中查找有关 Matrix Indexing 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by