3D Matrix multiplication with vector

前端 未结 4 523
一生所求
一生所求 2020-12-10 05:22

This bothers me a bit:

Suppose you have a matrix with three layers.

Is there a simple way to multiply this matrix with a vector of three elements so that the

4条回答
  •  感动是毒
    2020-12-10 06:02

    There's a matlab function called repmat that'll help you in this.

    M = [1 2 3]
    M * repmat([1 2 3], 3,1)
    ans =
    
     6    12    18
     6    12    18
     6    12    18
    
    M = [1 2 3]
    M .* repmat([1 2 3], 3,1)
    ans =
    
     1     4     9
     1     4     9
     1     4     9
    

    Depending on how exactly you want to organise your matrices.

提交回复
热议问题