| MATLAB® | ![]() |
This section summarizes the principal functions used in creating and handling matrices. Most of these functions work on multidimensional arrays as well.
Functions to Create a Matrix
Function | Description |
|---|---|
[a,b] or [a;b] | Create a matrix from specified elements, or concatenate matrices together. |
Construct a matrix using accumulation. | |
Construct a block diagonal matrix. | |
Concatenate matrices along the specified dimension. | |
Create a diagonal matrix from a vector. | |
Concatenate matrices horizontally. | |
Create a square matrix with rows, columns, and diagonals that add up to the same number. | |
Create a matrix of all ones. | |
Create a matrix of uniformly distributed random numbers. | |
Create a new matrix by replicating or tiling another. | |
Concatenate two or more matrices vertically. | |
Create a matrix of all zeros. |
Functions to Modify the Shape of a Matrix
Function | Description |
|---|---|
ctranspose | Flip a matrix about the main diagonal and replace each element with its complex conjugate. |
Flip a matrix along the specified dimension. | |
Flip a matrix about a vertical axis. | |
Flip a matrix about a horizontal axis. | |
Change the dimensions of a matrix. | |
Rotate a matrix by 90 degrees. | |
Flip a matrix about the main diagonal. |
Functions to Find the Structure or Shape of a Matrix
Function | Description |
|---|---|
Return true for 0-by-0 or 0-by-n matrices. | |
Return true for 1-by-1 matrices. | |
Return true for sparse matrices. | |
Return true for 1-by-n matrices. | |
Return the length of a vector. | |
Return the number of dimensions in a matrix. | |
Return the number of elements in a matrix. | |
Return the size of each dimension. |
Functions to Determine Class
Function | Description |
|---|---|
Return true if the matrix is a cell array. | |
Return true if matrix elements are characters or strings. | |
Determine if input is a floating point array. | |
Determine if input is an integer array. | |
Return true if matrix elements are logicals. | |
Return true if matrix elements are numeric. | |
Return true if matrix elements are real numbers. | |
Return true if matrix elements are MATLAB® structures. |
Functions to Sort and Shift Matrix Elements
Function | Description |
|---|---|
Circularly shift matrix contents. | |
Return true if the matrix elements are sorted. | |
Sort elements in ascending or descending order. | |
Sort rows in ascending order. |
Functions That Work on Diagonals of a Matrix
Function | Description |
|---|---|
Construct a block diagonal matrix. | |
Return the diagonals of a matrix. | |
Compute the sum of the elements on the main diagonal. | |
Return the lower triangular part of a matrix. | |
Return the upper triangular part of a matrix. |
Functions to Change the Indexing Style
Function | Description |
|---|---|
Convert a linear index to a row-column index. | |
Convert a row-column index to a linear index. |
Functions for Working with Multidimensional Arrays
Function | Description |
|---|---|
Concatenate arrays. | |
Shift array circularly. | |
Inverse permute array dimensions. | |
Generate arrays for n-dimensional functions and interpolation. | |
Return the number of array dimensions. | |
Permute array dimensions. | |
Shift array dimensions. | |
Remove singleton dimensions. |
![]() | Multidimensional Arrays | Built-In Classes (Data Types) | ![]() |
| © 1984-2008- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |