MATLAB Programming

MATLAB Programming MATLAB Programming

cda.psych.uiuc.edu
from cda.psych.uiuc.edu More from this publisher
23.06.2015 Views

1 Data Structures Summary of Matrix and Array Functions This section summarizes the principal functions used in creating and handling matrices. Most of these functions work on multidimensional arrays as well. FunctionstoCreateaMatrix Function [a,b] or [a;b] accumarray blkdiag cat diag horzcat magic ones rand repmat vertcat zeros Description 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 ctranspose flipdim fliplr Description 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. 1-72

Summary of Matrix and Array Functions Functions to Modify the Shape of a Matrix (Continued) Function flipud reshape rot90 transpose Description Flipamatrixaboutahorizontalaxis. 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 isempty isscalar issparse isvector length ndims numel size 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 Data Type Function iscell ischar isfloat isinteger islogical isnumeric 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. 1-73

1 Data Structures<br />

Summary of Matrix and Array Functions<br />

This section summarizes the principal functions used in creating and handling<br />

matrices. Most of these functions work on multidimensional arrays as well.<br />

FunctionstoCreateaMatrix<br />

Function<br />

[a,b] or [a;b]<br />

accumarray<br />

blkdiag<br />

cat<br />

diag<br />

horzcat<br />

magic<br />

ones<br />

rand<br />

repmat<br />

vertcat<br />

zeros<br />

Description<br />

Create a matrix from specified elements, or concatenate<br />

matrices together.<br />

Construct a matrix using accumulation.<br />

Construct a block diagonal matrix.<br />

Concatenate matrices along the specified dimension.<br />

Create a diagonal matrix from a vector.<br />

Concatenate matrices horizontally.<br />

Create a square matrix with rows, columns, and<br />

diagonals that add up to the same number.<br />

Create a matrix of all ones.<br />

Create a matrix of uniformly distributed random<br />

numbers.<br />

Create a new matrix by replicating or tiling another.<br />

Concatenate two or more matrices vertically.<br />

Create a matrix of all zeros.<br />

Functions to Modify the Shape of a Matrix<br />

Function<br />

ctranspose<br />

flipdim<br />

fliplr<br />

Description<br />

Flip a matrix about the main diagonal and replace each<br />

element with its complex conjugate.<br />

Flip a matrix along the specified dimension.<br />

Flip a matrix about a vertical axis.<br />

1-72

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!