What is the difference between *
and .*
in Matlab?
* is matrix multiplication while . * is elementwise multiplication. In order to use the first operator, the operands should obey matrix multiplication rules in terms of size.
* is matrix multiplication, . * is array multiplication (i.e. element-wise).
Description. example. C = A . * B multiplies arrays A and B by multiplying corresponding elements. The sizes of A and B must be the same or be compatible.
*
is a vector or matrix multiplication
.*
is a element wise multiplication
a = [ 1; 2]; % column vector
b = [ 3 4]; % row vector
a*b
ans =
3 4
6 8
while
a.*b.' % .' means tranpose
ans =
3
8
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With