Vectors And Matrices Flashcards
linspace (x, y, n)
Creates a linearly spaced vector.
x = start
y = end
n = step
Creating vectors v = x y z
v = [x y z] v = [x,y,z] v = x:z
logspace (x, y, n)
Creates a logarithmically spaced function
10^x = start
10^y = end
n = number of elements
Indexing
vec (x)
Returns the x element in vector vec
vec (x:y)
Returns elements from x to y inclusive.
vec (x) = y
Sets x-th element to y
Creating column vectors
v = [x;y;z] v = [x,y,z]'
Creating matrices
mat = [a,b,c; x,y,z] mat = [a b c; x y z]
rand (n)
Creates an n x n matrix of random numbers between 0 and 1.
rand (m, n)
Creates an m x n matrix of random numbers between 0 and 1.
randi ([intmin, intmax], m, n)
Creates an m x n matrix of random integers between intmin and intmax inclusive.
zeros (m, n)
Creates an m x n matrix of zeros.
ones (m, n)
Creates an m x n matrix of ones.
mat (x, :)
Refers to the x-th row
mat (:, x)
Refers to the x-th column.