필터 지우기
필터 지우기

Sparse Matirx

조회 수: 1 (최근 30일)
David Chen
David Chen 2011년 11월 21일
편집: John D'Errico 2018년 3월 17일
How to code sparse matrix from the existing matrix?

답변 (2개)

Andrei Bobrov
Andrei Bobrov 2011년 11월 21일
A = rand(10)
A(A>.15) = 0 % existing matrix
Asp = sparse(A) % sparse matrix
  댓글 수: 1
KAKOLI DEY
KAKOLI DEY 2018년 3월 17일
if I take temperature data matrix how would i convert yhis into a sparse

댓글을 달려면 로그인하십시오.


John D'Errico
John D'Errico 2018년 3월 17일
편집: John D'Errico 2018년 3월 17일
From what existing matrix? In what form?
If you already have a matrix, then the sparse function will convert it to sparse form. Thus
A = rand(6);
A(A > .1) = 0;
A here is a FULL matrix, even though it is mostly zero.
A
A =
0 0 0 0 0 0
0 0.084436 0 0 0 0
0 0 0 0 0.075967 0.049654
0.0046342 0 0 0 0 0
0 0 0 0 0 0
0 0 0 0 0 0
As you can see, A is full, just a double precision matrix.
whos A
Name Size Bytes Class Attributes
A 6x6 288 double
A is convertible into sparse form, trivially, using sparse.
As = sparse(A)
As =
(4,1) 0.0046342
(2,2) 0.084436
(3,5) 0.075967
(3,6) 0.049654
whos As
Name Size Bytes Class Attributes
As 6x6 120 double sparse
If you have a matrix in some other form, perhaps a list of row and column indices and values, then again, sparse does the job.
Or, perhaps you have the matrix in the form of known diagonals. Then spdiags is the proper tool.
But we cannot read your mind as to what you have. Just telling us that you have a "temperature data matrix" is nothing of value. It is insufficient information.

카테고리

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