Please enable JavaScript.
Coggle requires JavaScript to display documents.
Matrices and Arrays (Matrix and Array Operations (a1 * a2; performs…
Matrices and Arrays
Matrix and Array Operations
a = an array; a + 10 adds 10 to every number in a
sin(a); takes sin of every num
a'; transposes a; switches rows and colums
a1 * a2; performs standard matrix multiplication
a1 .* a2; perform element-wise multiplication, not
matrix multiplication
inv(a); inverts a matrix
multiplication, division, and power each have a corresponding array operator that operates element-wise
.^3 would raise every val in a to 3
A = [a,a]; concatenates arrays - horizontal concatenation, both arrays must have the same number of rows
A = [a ; a] - vertical concatenation, both arrays must have the same number of columns
array creation
single line array
a = [ -, -];
multi-line
ex: 3x3 a = [1 2 3; 4 5 6; 7 8 10]
create them with functions
functions ones, zeros, rand
z = zeros(5,1) - 5x1 array of zeros
tips
to get more decimal digits use - format long - reset to normal decimal amount with - format short