M4: zyBook Activities Multiple Choice
Row Column Integer indexing
Can return a 2D array
Linear Integer indexing
Will always return a 1D Array
Indexing with a 2D Logical Array
Will always return a column array
linear indexing array
a special type of integer array that uses a single index to extract from a 2D array
indexing array
a special type of integer array used for indexing
integer indexing array
a special type of integer array used for indexing
integer array
an array of integers
indexed array
an array that is being accessed by an indexing array
With linear indexing, what is the integer index array to display the cMat(1,1) and the cMat(2,2) as a column? (cMat = [[10,20] ; [30,40]])
cMat([1;4])
With row-column indexing, what is the logical index array to display both the cMat(1,1) and the cMat(2,2) as a row? (cMat = [[10,20] ; [30,40]])
cMat([[true, false]; [false, true]])'
sampleMatrix([2:4]') (yields a what?)
column array (of indexes 2 through 4 in flattened sampleMatrix)
logical indexing must index all elements of an array
false
sampleMatrix([n])
flattens and removes a value from a matrix
sampleMatrix([n])=[]
flattens and removes a value from sampleMatrix
logical array
indexing with this array for a matrix yields a column; indexing with this array for a row array yields a row.
mat(n:m)=[]
removes elements n:m in an array (or removes elements n:m and flattens matrix)
x1=x2(:)
replaces x1 with a COLUMN array consisting of all the elements in x2
x2=x1(:)'
replaces x2 with a ROW array of all elements in x2
reshape(matrix, row, col)
reshapes the matrix
array(:)
returns column array of all elements in array
size(array, 2)
returns the column sizes
size(array)
returns the dimensions of an array
length(array)
returns the length of a 2D array
numel(array)
returns the number of values in an array
Linear indexing with a row array
will always return a row array