MATLAB: Sparse matrix

matricesmatrixsparsparse

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.

Best Answer

blkdiag(speye(30886,30886),sparse(68709-30886,130478-30886));