sparse matrix
조회 수: 9 (최근 30일)
이전 댓글 표시
I am trying out to form a sparse matrix but it runs out of memory.Below is the code similar to which I have been working on A=sparse(15000,15000); inb=sparse(eye(10000,10000); it goes out of memory here.
So for forming a identity matrix (inb) I use: inb=sparse(10000,10000); for i=1:1:10000; inb(i,i)=ones; end A(1:10000,1:10000)=inb; it goes out of memory. Is there any way I can get rid of this.
댓글 수: 0
채택된 답변
추가 답변 (3개)
the cyclist
2011년 8월 24일
Try the speye() command.
댓글 수: 3
the cyclist
2011년 8월 24일
I have no problem running that code, and it results in the sparse arrays I expect.
Walter Roberson
2011년 8월 25일
aeq=sparse(68709,130478);
generates an empty 68709 by 130478 sparse matrix, with the number of expected non-zero elements set to 0. But then you set a whole bunch of elements to non-zero, which requires reorganizing the sparse matrix as it detects more and more non-zero elements.
If you were to use
aeq=sparse([], [], [], 68709,130478, 30886);
then it would probably have less difficulty.
Rahul Pal
2020년 8월 2일
function y = caesar2(ch, key)
v = ' ' : '~';
[~, loc] = ismember(ch, v);
v2 = circshift(v, -key);
y = v2(loc);
end
댓글 수: 0
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!