create big matrix with only 0s and 1s
3 次查看(过去 30 天)
显示 更早的评论
I want to run the following
n = 10^6;
m = n/2;
H = sparse(m,n);
parfor jj=1:n
pos = sample(cumulative);
H(:,jj) = (rand(m,1) > 1 - degrees(pos)/m);
end
but the memory is over.
degrees(pos)/m is a different number every time. Is there any way to run it quickly?
0 个评论
回答(1 个)
the cyclist
2013-11-6
Unless I did the math in my head wrong, you are trying to create a matrix that is 4 terabytes of data (and is not actually sparse). That's too big.
2 个评论
Image Analyst
2013-11-6
theodor, why do you need it that big? You'll just have to get by without the whole thing in memory at once. You'll have to figure out how to process the thing in smaller chunks.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Creating and Concatenating Matrices 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!