• Converting Full to Sparse
• Creating Sparse Matrices Directly
• Creating Sparse Matrices from Their Diagonal Elements
MATLAB® software never creates sparse matrices automatically. Instead, you must determine if a matrix contains a large enough percentage of zeros to benefit from sparse techniques.
The density of a matrix is the number of nonzero elements divided by the total number of matrix elements. For matrix M, this would be