Algorithm::Permute
.permute
returns. During the execution of the callback, the array is read-only and you'll get an error if you try to change its length. (You can change its elements, but the consequences are liable to confuse you and may change in future versions.)return
, and you can't jump out of it using goto
and so on. Also, caller
won't tell you anything helpful from inside the callback. Such is the price of speed.List::Permutor
. Robin Houston <[email protected]> invented and contributed the callback style interface.A(:,:,2)
uses a colon in the first and second dimensions to include all rows and all columns from the right-hand side of the assignment. cat
function can be a useful tool for building multidimensional arrays. For example, create a new 3-D array B
by concatenating A
with a third page. The first argument indicates which dimension to concatenate along.B
that contains all zeros. A
, which is in the first row, second column, and second page of A
. [1 3]
in the second dimension to access only the first and last columns of each page of A
. reshape
, permute
, and squeeze
are useful functions for rearranging elements. Consider a 3-D array with two pages. reshape
function to rearrange the elements of the 3-D array into a 6-by-5 matrix.reshape
operates columnwise, creating the new matrix by taking consecutive elements down each column of A
, starting with the first page then moving to the second page. M
.permute
function to interchange row and column subscripts on each page by specifying the order of dimensions in the second argument. The original rows of M
are now columns, and the columns are now rows.M
.squeeze
function performs another type of manipulation that eliminates dimensions of length 1. For example, use the repmat
function to create a 2-by-3-by-1-by-4 array whose elements are each 5, and whose third dimension has length 1. squeeze
function to remove the third dimension, resulting in a 3-D array.