Documentation

This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

Matrices and Arrays

Array creation, combining, reshaping, rearranging, and indexing

Matrices and arrays are the fundamental representation of information and data in MATLAB®. You can create common arrays and grids, combine existing arrays, manipulate an array’s shape and content, and use indexing to access array elements. For an overview of matrix and array manipulation, watch Working with Arrays.

Functions

zerosCreate array of all zeros
onesCreate array of all ones
randUniformly distributed random numbers
trueLogical 1 (true)
falseLogical 0 (false)
eyeIdentity matrix
diagCreate diagonal matrix or get diagonal elements of matrix
blkdiagConstruct block diagonal matrix from input arguments
catConcatenate arrays along specified dimension
horzcatConcatenate arrays horizontally
vertcatConcatenate arrays vertically
repelemRepeat copies of array elements
repmatRepeat copies of array
linspaceGenerate linearly spaced vector
logspaceGenerate logarithmically spaced vector
freqspaceFrequency spacing for frequency response
meshgrid2-D and 3-D grids
ndgridRectangular grid in N-D space
lengthLength of largest array dimension
sizeArray size
ndimsNumber of array dimensions
numelNumber of array elements
isscalarDetermine whether input is scalar
isvectorDetermine whether input is vector
ismatrixDetermine whether input is matrix
isrowDetermine whether input is row vector
iscolumnDetermine whether input is column vector
isemptyDetermine whether array is empty
sortSort array elements
sortrowsSort rows of matrix or table
issortedDetermine if array is sorted
issortedrowsDetermine if matrix or table rows are sorted
topkrowsTop rows in sorted order
flipFlip order of elements
fliplrFlip array left to right
flipudFlip array up to down
rot90Rotate array 90 degrees
transposeTranspose vector or matrix
ctransposeComplex conjugate transpose
permuteRearrange dimensions of N-D array
ipermuteInverse permute dimensions of N-D array
circshiftShift array circularly
shiftdimShift dimensions
reshapeReshape array
squeezeRemove singleton dimensions
colonVector creation, array subscripting, and for-loop iteration
endTerminate block of code, or indicate last array index
ind2subSubscripts from linear index
sub2indConvert subscripts to linear indices

Topics

Creating and Concatenating Matrices

Create a matrix or construct one from other matrices.

Matrix Indexing

Access or assign to elements of a matrix using methods of row and column indexing.

Resizing and Reshaping Matrices

Change the size, shape, or arrangement of elements in an existing matrix.

Shifting and Sorting Matrices

Shift matrix elements along one or more dimensions, or sort them into ascending or descending order.

Operating on Diagonal Matrices

Construct and manipulate matrices along a diagonal.

Empty Matrices, Scalars, and Vectors

Work with matrices that have one or more dimensions equal to zero or one.

Multidimensional Arrays

Create and work with arrays that have more than two dimensions.

Was this topic helpful?