The matlab dot() function finds the matrix inner product, three-dimensional, multi-dimensional detailed explanation

The matlab dot() function finds the matrix inner product, three-dimensional, multi-dimensional detailed explanation

A=\begin{bmatrix} a1,a2,a3 \\ a4,a5,a6 \end{bmatrix}

B=\begin{bmatrix} b1,b2,b3\\ b4,b5,b6 \end{bmatrix} 

C=dot(A,b,X), this parameter X can only take 1 or 2. 1 means by column, 2 means by row, if there is no parameter. By column by default.
 

1) Calculate by column first

 C=dot(A,B)=dot(A,B,1)

=[a1*b1+a4*b4 ,a2*b2+a5*b5 ,a3*b3+a6*b6].

This is a vector with 1 row and 3 columns.

2) Row-first calculation

 C=dot(A,B,2)

=[a1*b1+a2*b2+a3*b3 ;a4*b4+a5*b5+a6*b6 ].

This is a vector with 2 rows and 1 column

 C=dot(A,B,2)

=[a1*b1+a2*b2+a3*b3 ;a4*b4+a5*b5+a6*b6 ].

Examples are as follows

a1 =

     1     2     3
     2     3     4

>> b1=[4,5,6;5,6,7]

b1 =

     4     5     6
     5     6     7

>> dot(a1,b1)

ans =

    14    28    46

>> dot(a1,b1,2)

ans =

    32
    56

>> 

Extend the theory

 

 

 

 

Guess you like

Origin blog.csdn.net/Vertira/article/details/131825634