Obtaining sparse matrix indices

조회 수: 9 (최근 30일)
Kalpanie Mendis
Kalpanie Mendis 2020년 8월 31일
댓글: Kalpanie Mendis 2020년 8월 31일
Hi,
I am using sparse function to obtain non-zero elements of a matrix. for example,
s= sparse(M)
(1,1) -5.0000
(2,1) 1.0000
(8,1) 5.0000
(1,2) 5.0000
(2,2) -6.0000
Now I want to creat3 3 arrays containing the row indices, column indices and value indices of the output. For intance,
A_i= [1,2,8,1,2] : row vector, i of Matrix(i,j).
A_j= [1,1,1,2,2]: row vector, j of Matrix(i,j).
A_s= [-5,1,5,5,-6]: row vector, value of the element: A(A_i(m),A_j(m))=A_s(m).
How can I create the matrix A from the output of the sparse function?

채택된 답변

Steven Lord
Steven Lord 2020년 8월 31일
Use find.
  댓글 수: 1
Kalpanie Mendis
Kalpanie Mendis 2020년 8월 31일
Thanks. figured it now :)

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

추가 답변 (0개)

카테고리

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

태그

제품


릴리스

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by