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

4 vues (au cours des 30 derniers jours)
Daniel Lyddy
Daniel Lyddy le 20 Fév 2011
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?

Réponses (1)

Bruno Luong
Bruno Luong le 20 Fév 2011

Catégories

En savoir plus sur Operating on Diagonal Matrices dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by