matlab week 1.2 Flashcards
vectors
one dimensional collection of variables written between brackets []
[1 2 3 4 5 ]
row vector
[1; 2; 3; 4; 5]
column vector
size(x)
returns dimensions of row (two values, n by m)
length(x)
returns number of elements in a vector (one value)
linspace
generates row vector of n points between and including two points
y = linspace(a, b, n)
what does each letter represent?
y is the created row vector
a is the starting number, included
b is the end number, included (if it fits in increment)
n is the number of points generated
linspace(1,5)
returns 1 by 100 vector between 1 and 5
default ‘n’ if not specified by linspace function
100
linspace(1, 5, 1)
5
you generated one number between 1 and 5 so it took a stepsize of 5
t = [1 2 3]
y = log(t)
what is y?
y = [ log(1), log(2), log(3) ]
element wise operations
use dot
.* ./ .^
transpose
converts column vector into a row vector and vice versa (‘)
a = [ 1 2 3]
a’
a =
1
2
3
b = [ 1, 2, 3, 4 + i]
b’
b =
1
2
3
4 - i