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
expand all
Create and Combine Arrays
zeros | Create array of all zeros |
ones | Create array of all ones |
rand | Uniformly distributed random numbers |
true | Logical 1 (true) |
false | Logical 0 (false) |
eye | Identity matrix |
diag | Create diagonal matrix or get diagonal elements of matrix |
blkdiag | Block diagonal matrix |
cat | Concatenate arrays |
horzcat | Concatenate arrays horizontally |
vertcat | Concatenate arrays vertically |
repelem | Repeat copies of array elements |
repmat | Repeat copies of array |
Determine Size, Shape, and Order
length | Length of largest array dimension |
size | Array size |
ndims | Number of array dimensions |
numel | Number of array elements |
isscalar | Determine whether input is scalar |
issorted | Determine if array is sorted |
issortedrows | Determine if matrix or table rows are sorted |
isvector | Determine whether input is vector |
ismatrix | Determine whether input is matrix |
isrow | Determine whether input
is row vector |
iscolumn | Determine whether input
is column vector |
isempty | Determine whether array is empty |
Indexing
colon | Vector creation, array subscripting, and for -loop
iteration |
end | Terminate block of code or indicate last array index |
ind2sub | Convert linear indices to subscripts |
sub2ind | Convert subscripts to linear indices |