How can I pre allocate the memory of a huge highly sparse data.

1 view (last 30 days)
Hello all,
Sid=sparse(2.500.000,250.000);
for t=1:11
for i=1:250.000
Sid(ind((i,t)),i)=leng(i,t);
end
Sis(t).f={Sid};
end
The problem I have is to find a way to pre-allocate the memory for my use. Let me briefly explain the code I use and some important things .
"Sid" sparse matrix consists of 250.000(from 1 to 250.000) elements which contains not more than 500 non-zero elements out of 2.500.000!
"Sid" sparse matrix changes 11 times and all of these data needs to be stored to be used in the next part of the program.
leng which is stored as cell array contains the values of non zero elements.
ind which is also stored as cell array contains the pixel location of the related "leng"
ind(i,t) and leng(i,t) are vectors with an element of less than 500.
The problems are as you already guessed the memory and the computational cost of the code. It runs over a day and is still running. I know that preallocating the Sid matrix is impossible and matlab works much faster when the variable is pre assigned but this is what I have.
Any help to speed it up?
Sorry for keeping the questions and details so long.
Thanks

Answers (0)

Categories

Find more on Performance and Memory in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!