필터 지우기
필터 지우기

Changing a single element in sparse matrices

조회 수: 7 (최근 30일)
Jong Hyun Chung
Jong Hyun Chung 2011년 11월 21일
I am not very familiar with Matlab and struggling with handling large matrices.
The problem involves about 600000 points and their interactions with each other. I tried to model this with 600000 by 600000 matrix where each element is either 1 or 0, in which 1 represents that the row's point has an interaction with the column's point.
I created the initial matrix with M = speye(600000). Then I tried to run for-loop for each row, converting some chosen elements in that row into 1. To do so, I used the usual M(r,c) = 1 command. Matlab warns me that such indexing expression would be slow, and it indeed is.
Is there a way to modify sparse matrix more efficiently? More broadly, what are the strategies for dealing with such large but simple (in that elements are binary) matrices?
Any sort of advice would be much appreciated.

답변 (1개)

Sarah Wait Zaranek
Sarah Wait Zaranek 2011년 11월 21일
In general, it is useful to define the values and locations of the non-zero entries of your sparse matrices - and then only create it once.
There is a useful section in the MATLAB documentation about dealing with sparse matrices here: http://www.mathworks.com/help/releases/R2011b/techdoc/math/f6-32006.html
In particular, look at the sections about accessing and creating sparse matrices for examples.

카테고리

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