Here is my code:
rows = zeros(round(a large number),1);
cols = rows;
vals = rows;
rows(idx) = (i-1)*p + j;
cols(idx) = col;
vals(idx) = d;
Here, idx, pj, col, d are four arrays of the same size. The first indexing line (rows(idx) = (i-1)*p + j;) gets no problem. But when excuting the next line, it comes the problem "out of memory".
I set a breakpoint and debug here. After excuting "rows(idx) = (i-1)*p + j;", i tried "cols(1)=1", it also got the out of memory problem. Could someone pleas explain this problem to me? Thanks a lot!