Matrix-Vector Arithmetic
Create a row vector
b = [1 2 3 4]
b = 1 2 3 4
a column vector
c = [2; 4; 6]
c = 2 4 6
and a matrix
A = [1 2 3; 2 3 4; 5 6 7; 8 9 0]
A = 1 2 3 2 3 4 5 6 7 8 9 0
Two different matrix-vector products
b*A
ans = 52 62 32
or
A*c
ans = 28 40 76 52
Many MATLAB functions accept matrix arguments
sqrt(A)
ans = 1.0000 1.4142 1.7321 1.4142 1.7321 2.0000 2.2361 2.4495 2.6458 2.8284 3.0000 0
sin(b)
ans = 0.8415 0.9093 0.1411 -0.7568
exp(c)
ans = 7.3891 54.5982 403.4288
Other component-wise operations are done using the . operator
b.^2
ans = 1 4 9 16
The following is also possible
A.^A
ans = 1 4 27 4 27 256 3125 46656 823543 16777216 387420489 1