I have sparse matrix. I want to change entry [2;3;5] to [0.01;3.4;4.1]
A=[1,0,0,0,0;0,2,0,0,0;0,0,4,0,0;0,0,0,3,0;0,0,0,0,6];
sparse(A);
out=[0.01;3.4;4.1];
inx=[2;3;5];
rssult should be
(1,1) 1
(2,2) 0.01
(3,3) 3.4
(4,4) 3
(5,5) 4.1
I do not know how to change entry of sparse matrix

댓글 수: 1

Bruno Luong
Bruno Luong 2019년 8월 10일
you forgot to assign sparse(A) to a variable

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

 채택된 답변

Bruno Luong
Bruno Luong 2019년 8월 10일
편집: Bruno Luong 2019년 8월 10일

0 개 추천

Change it exactly like regular (non-sparse) matrix:
A(sub2ind(size(A), inx, inx)) = out

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Sparse Matrices에 대해 자세히 알아보기

질문:

NA
2019년 8월 10일

댓글:

2019년 8월 10일

Community Treasure Hunt

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

Start Hunting!

Translated by