You are on page 1of 1

Matlab

Vectors
x = [7 6 5 4 3 2 1] => line vector
x = [7 ; 6 ; 5 ; 4 ; 3 ; 2 ; 1] => column vector
x(a:b) => shows elements of vector x from the a coloumn till the b column
final column => has value end
-value => shows column 1 + value
x(a:b:c) => shows elements of vector x for the column a, b, c
y = x([a a b a a]) => creates a vector y from vector x, element in column a
in vector x will be assigned to vector y.
Matrix
A = [3 2 5; 2 6 1; 1 7 3] => 3x3 matrix
x1 = A([4:6]) => x1 line vector of the second column of A
y1 = A([1:3 ; 4:6]) => y matrix with row 1 = column 1 of A, row 2 = column
2 of A
S = sum(A,1) => line vector of sums of all
S = sum(A,2)
S = sum(A,3)

You might also like