# MATLAB Programming/Sparse Matrices

From Wikibooks, open books for an open world

A **Sparse Matrix** is a matrix that mostly contains zeros. In MATLAB, sparse matrices contrast regular ones in the way they are stored, such that memory is used more efficiently for matrices that are sparse.

A regular matrix can be converted to a sparse matrix using

>> S = sparse(A); % Create sparse representation of A

Sparse matrices are very common in engineering purposes. This is useful for manipulation as most of the matrix has a value of 0.