简体   繁体   中英

Matlab - multiply matrix with vector of matrices

I have a matrix of scalars (A):

    1  2  3 
    4  5  6 
    7  8  9 

And 3 other matrices of the same size ( 100X200 ), B,C,D.

I want to do the following:

A*[B,C,D] so that the outcome will be [1*B + 2*C + 3*D, 4*B + 5*C + 6*D, 7*B + 8*C + 9*D] .

Using normal multiplication * does not work since [B,C,D] obviously isn't of size 3X3 . How can it be done correctly?

  • What you want to do is this giant sparse matrix multiplication

    无花果

    where I is the identity matrix, and the above are stacked vectors and matrix where all the rows and columns are appended together.

  • What you should do as mentioned in the comments is to use the .* operator to write

    F = 1.*B + 2.*C + 3.*D G = 4.*B + 5.*C + 6.*D H = 7.*B + 8.*C + 9.*D

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM