chapter 10 Flashcards
2D array / matrix
elements in rows and columns
creating a matrix
[[row1] ; [row2]]
separate rows by semicolons
indexing with coordinate
temps(row, column) = 75
row-column indexing
conventional approach, uses indices to index
linear indexing
single index used to refer to array element
equation for linear indexing
m*(y-1) + x
for spot (x,y) and a total of m rows in the matrix
out of range indices
only resizable with row column indexing, otherwise error
integer indexing array
section of numbers used to index an array
indexing with array
weight(1, [1, 2, 3])
integer indexing
weight(1, 1:3)
linear indexing
weight([3, 4, 5])
flattening an array
unwinding a 2D array into column
sampleMatrix(:)
array reshaping
make 1D array into 2D
sampleMatrix(:) = 1
makes all the elements 1
sampleMatrix(:, 2) = [ ]
deletes column 2