Clear Filters
Clear Filters

I am having trouble finding the source of an indexing error

1 view (last 30 days)
I am dealing with some large arrays and I keep getting the error: “Indices must be real positive integers or logical” or “Index exceeds size.” The vector of indices is created through the function ALLCOMB. The inputs to ALLCOMB are vectors of positive integers, so the output should be a matrix of positive integers. I have been able to find the location of the offending index on several occasions and it turns out to be a 6+eps or a 9+eps rather than a 6 or a 9. The truly puzzling part though, is that I cannot change these values in my vector. While in debugging mode, I have tried to round the vector, change the data type to int8 or uint8, and I have even manually typed in the correct integer values, but to no avail. I will type in A(1,7819)=9, then check the value before moving on, and it is still 9+eps.
Also, when I get the error “Index exceeds size,” I will view the max and min of my vector of indices to find that they are in fact well within the size of the referenced array.
I am also getting “out of memory” errors on programs that have successfully run only minutes before. I increased the Java Heap size, but with no effect.
I am starting to suspect an issue with my system, any suggestions? I’ll list my system specs below:
Machine: iMac 21.5-inch Mid 2011 Processor: 2.8 GHz Intel Core i7 Operating system: OS X 10.8.3 Memory: 32 GB DDR3 Storage: 251 GB Flash with 172GB free and a 2TB SATA (MATLAB installed on Flash)

Answers (1)

Image Analyst
Image Analyst on 28 May 2013
Well we can't do much without seeing any code. But I'd say that if you cast the indexes, "A", to integers and it's still saying that, then you must have 0 or negative numbers, or a positive number greater than numel of whatever array you're trying to use "A" as indices for, or greater in one of the dimensions. Of course if you really cast to int32, then no number is going to be an integer plus eps. 32 gigabytes of RAM is impressive and should handle most MATLAB programs. Tell me this:
size(theArray) % The size of the array A will be used as indices for.
minA = min(A(:)) % No semicolon so it will print to the command window.
maxA = max(A(:)) % No semicolon so it will print to the command window.
  5 Comments
Image Analyst
Image Analyst on 28 May 2013
My gosh - why is A so huge? Why do you need indexes that go as high as 170 million? I've never had an index go that high.
Brent
Brent on 28 May 2013
Well, the indices only range from 1-15, but are stacked in specific sequences for a total of 170 mil rows. The program is meant to enumerate all of the possible combinations of m binary decisions made by n agents, less some logical discrepancies. I am working on an algorithm that avoids such enumeration, but for a proof of concept, I need to compare that algorithm to the fully explicit case where all combinations are used.

Sign in to comment.

Categories

Find more on Loops and Conditional Statements 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!