Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between * and .* in matlab?

What is the difference between * and .* in Matlab?

like image 411
Ajay Soman Avatar asked Apr 04 '13 11:04

Ajay Soman


People also ask

What is the difference between using * 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.

What is meaning of * in MATLAB?

* is matrix multiplication, . * is array multiplication (i.e. element-wise).

What is a * b in MATLAB?

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.


1 Answers

* 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
like image 140
Nick Avatar answered Sep 27 '22 21:09

Nick