필터 지우기
필터 지우기

checking Sparsity of matrix

조회 수: 11 (최근 30일)
SANJOY MONDAL
SANJOY MONDAL 2018년 2월 2일
편집: Stephen23 2018년 2월 2일
I have a matrix
[ 0.9
0.8
0.32
0.22
0
0
0.36
0.25
]
how to check whether a matrix is sparse matrix or not using matlab

답변 (1개)

Steven Lord
Steven Lord 2018년 2월 2일
Do you want to check whether it is represented in MATLAB using the sparse data structure (in which case the issparse function is the correct tool?) Or do you want to check if it is sparsely populated even though it is stored using the full data structure? In the latter case, use the nnz and numel functions to determine the number of non-zero elements and the total number of elements in the matrix. If the number of non-zero elements is much smaller (how much smaller it needs to be is up to you) than the total number of elements, you could call your matrix sparsely populated.
As written your vector is not stored as a sparse matrix according to issparse, nor would I say it is sparsely populated since 75% of the elements are non-zero. A glass that is 3/4 full of liquid and 1/4 full of air is not mostly empty, it's mostly full.

카테고리

Help CenterFile Exchange에서 Sparse Matrices에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by