lesson 2 Flashcards
what is an array?
what are the numbers within an array called?
can rows have different numbers of elements?
any set of numbers arranged in a rectangular patten
elements of an array
no, each row must have the same number of elements as every other row
what are matrices?
2d rectangular arrays made up of rows and columns
what do we call a 1d array?
what do we calla 2d array?
vector
matrix (plural - matrices)
some functions in matlab:
how do you write square root…
sin…
what does size do
sqrt
sin but for degrees its sind
size tells you the ‘size of the array e.g for a matrix the row and element number
a custom among people using matlab is to use ____ for vector’s and _____ for matrices
lowercase, uppercase
what does 1:3:7 mean and what would it display
what does 1:7 do
create a row starting from 1 increasing in values of 3 going no higher the 7
it would display 1 4 7
displays 1 to 7 increasing by 1 going no higher then 7 (so basically just numbers 1 to 7)
it would display 1 2 3 4 5 6 7
you write ______ to access any specific part of matrices
if there is no element in the area you have asked for then what does MATLAB do?
your write _____ or _____to find multiple elements separated in different rows or columns
how do you access the last row/column of a matrix?
you can find the second last row/column by using _____
> > x(2,3)
adds in the missing data for the all elements in the row and column you asked for as 0
x(2,[3,5]) gives elements in row 2 column 3 and 5
x([2,1], 2) gives elements in row 2 and 1 from column 2
use the key word ‘end’
e.g
x(end,[3,5]) gives elements in end row column 3 and 5
end-1
what is the short hand 1:end
how would you use it?
:
x(1:end, 2) would become x(:, 2) and still show all rows available in column 2
how do you add the matrix [10 20; 30 40; 50 60] to 2nd and 3rd column of the matrix x (the matrix x is 3 by 5 here)
x(:,[2:3]) = [10 20; 30 40; 50;60]
not you have to use : I think cuz : means 2 to 3 witch 2,3 does not
also if the right side matrix does not fit perfectly into the left side matrix you cant use 1:end and need to explicitly say the rows needed
e.g 1:3 in this case
how to combine matrices?
for the matrices to add together the end product must form a ______.
write as in you creating a normal matrix
e.g
x = [A1;A2;A3]
rectangle
what is the transposition operator in MATLAB?
what does it do when applied to mtracies
e.g
» G = H’
’
it turned rows into columns and columns into rows
H = [1 2 3; 4 5 6] into G = [1 4; 2 5; 3 6]
formal definition - indices are swapped:
H’(m,n) = H(n,m) for all m and n
matlab will always run _____ ____ ___ ______ before everything else
what’s inside the brackets
when doing arithmetic operation with matrices the matrixes must _____
agree (same size) (or one of them is a scalar)
what symbol do we use when multiplying arrays?
what symbol do we use when multiplying matrix?
what symbol do we use when dividing arrays?
what symbol do we use when dividing a matrix?
what symbol do we use for exponentials when doing operations with arrays and matrices?
.*
*
./
/
.^ and ^
(array and matrices operations are different (somehow idk how))
array multiplication:
when can you use matrix multiplication?
this means that…
matrix multiplication works by…
and give an algebraic example
when matrix A has the same number of columns as matrix B has rows.
matrix multiplication is not reversible.
e.g
AB =/ BA
multiplying rows by columns.
multiplying every element in a row from matrix A by its corresponding element in a column from matrix B.
notes - you only multiply them 1 for 1 not 1 for many (same number from matrix A/B is not multiplied twice)
e.g
0 0 1
*
7 6 9
3 7 9
2 3 2
=2,3,2
as
07+03+12 = 2 …ect
06+07+13 = 3
09+07+1*2 = 2
=2,3,2
resulting in the dimensions of the new matrix consisting of the number of rows form matrix A and the number of columns form matrix B
A(n,m) * B(m,u) = Z(n,u) (Z consists of M from A * M from B)