MATLAB: What is the difference between the given matrix multiplications: A*B and A.*B (A and B are both matrices)

MATLABmatrix

When I gave A*B MATLAB gave the predicted output, but when the "dot" precedes the "*" operator it gives some other output
a=[1 2 3;4 5 6;7 8 9];
x=a(:,2);
a.*x
The Output that I get for this is
ans =
2 4 6
20 25 30
56 64 72

Best Answer

a*x is the "usual" matrix-vector multiplication, a.*x is elementwise multiplication. In your case, every element of row i of a is multiplied by the i'th element of the vector x.
https://de.mathworks.com/help/matlab/ref/times.html
Best wishes
Torsten.