Out of memory error for loop code
1 次查看(过去 30 天)
显示 更早的评论
Hi everyone, I have a very simple code in which I want to find the correlation distances from one point to all the other points in the matrix. I am using bsxfun to find those distances and I am using imread as the function to read an image (The image will give me the points of the matrix).
Since the image is very big, matlab cannot make all the distances because I do not have enough memory in my computer. I tried using a supercomputer which is located in my univesity, the problem is that the supercomputer has only 96gb and I need more than that. I want to read the image by parts, but since I am trying to read the distances, it will change. For example
I have a matrix A:
1 0 0 0 1
0 0 1 0 0
1 0 0 0 1
0 0 0 0 1
1 0 0 0 1
For this matrix, the distances in the x axis of the first point with respect to the others will be:
[0 4 2 0 4 4 0 4]
And the distances in the y axis will be:
[0 0 1 2 2 3 4 4]
Lets say that I cut this matrix in two parts, and I would have 2 matrices like this:
1 0 0 0 1
0 0 1 0 0
1 0 0 0 1
and
0 0 0 0 1
1 0 0 0 1
If I try to make the y-axis distances for the first matrix, they will be:
[0 0 1 2 2]
but for the next matrix will be:
[0 1 1], instead of what I had before [3 4 4]
Does anyone know how can I solve this issue? Thank you.
5 个评论
Image Analyst
2014-2-17
Why do you need it all in memory at once? Why can't you just concentrate on one pair at a time in a nested for loop?
Iain
2014-2-17
For those of us not allowed to download stuff willy nilly from the net, can you define what "very big" means?
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Logical 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!