Out of memory error for loop code
显示 更早的评论
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
编辑:Image Analyst
2014-2-17
How did you arrive at these 8 numbers [0 4 2 0 4 4 0 4] as the distances from the upper left pixel to the other 24 pixels in this 5 by 5 image?
And, let's take a step back and ask WHY do think think you want this information. What will it do for you if you had it? Let's pretend you had infinite memory and were able to get the "correlation distance" or "distance" (whichever) - what would that do for you? What would you do with that information? And what is correlation distance exactly? Do you have a formula for it? I presume it's not just the Euclidean/Pythagorean distance = sqrt(deltaX^2+deltaY^2) but what is it?
Sebastian
2014-2-17
Sebastian
2014-2-17
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 个)
类别
在 帮助中心 和 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!