MATLAB: What is the simplest way to get an element of an matrix multiplication?

47 Views Asked by At

What is the simplest way to get an element of an matrix multiplication?

Assume $A$ and $B$ are $n\times n$ matricies. And $1\le i\le n$ and $1\le j\le n$ are inidicies

I tried $(A*B)(i,j)$ but this is no valid MATLAB syntax.

Sure an other way is $C=A*B$ and then $C(i,j)$ but this to complex and long for me.

Is there a trick to do that in a simple and compact way?

Thanks

1

There are 1 best solutions below

4
On BEST ANSWER

If $A$ and $B$ are $n \times n$ real matrices with $A=(a_{i,j})_{1 \leq i,j \leq n}$ and $B = (b_{i,j})_{1 \leq i,j \leq n}$, for a given $(i,j) \in \lbrace 1,\ldots,n \rbrace^{2}$,

$$ \big( AB \big)_{i,j} = \sum_{k=1}^{n} a_{i,k}b_{k,j} $$

As a consequence, you could try : dot(A(i,:)',B(:,j)) in MATLAB.