Understanding the difference between normal multiplication between two vectors and multiplication with dot operator.
Show older comments
Hello all, I am trying to understood the difference between normal multiplication and mutliplication with dot operator in caseof two vectors.
For example,
If we have two vector H of dimension 2 X 4 and B of dimension 4 X 1 then writing
Y = H*B % ---(1)
do not cause any error.
But if we write
Y = H.*B %--- (2)
then it gives the following error: Arrays have incompatible sizes for this operation.
Any help is highly appreciated.
4 Comments
Dyuman Joshi
on 20 Oct 2023
Edited: Dyuman Joshi
on 20 Oct 2023
Element-wise multiplication can be done for arrays of uneqal size as well -
x = rand(1,3);
y = eye(3);
z = x.*y
The necessity for this it to have compatible size - Compatible Array Sizes for Basic Operations
"the second case is explained here"
No, element-wise array multiplication is definitely not explained by the DOT documentation.
However it is explained by the TIMES documentation:
Also very important to read and understand:
@Dyuman Joshi: it is true. Note however that Mathieu NOE has confused DOT with TIMES.
Walter Roberson
on 20 Oct 2023
MATLAB does not have any dot operator. MATLAB has a series of operators whos representation involves two characters, the first of which happens to be a dot.
So in A.*B that is not parsed as A followed by an operator '.' followed by an operator '*' followed by B: it is parsed as A followed by a single operator designated by '.*' followed by B.
This is similar to the way that A>=B is not parsed as A followed by a > operator then a = operator then B, but is instead A followed by a single operator designed by '>=' followed by B
chaaru datta
on 20 Oct 2023
Answers (0)
Categories
Find more on Logical in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!