- #1
sarawayland76
- 3
- 0
Hello!
I consider myself typically a confident Matlab user. But I have encountered a new problem that I have no idea how to solve, so I'm hoping I can find some help.
I have set up a for loop in my code to the effect of
for i = 1:n
end
The code runs fine for small values of n. But, when I have a very large n (somewhere near 50,000), I get an error message:
? Attempted to access MyArray(NaN,1); index must be a positive integer or logical.
And, checking on the value of the index i, it has become NaN.
I don't understand how this is possible as Matlab should be incrementing i itself within the for loop. (I promise I'm not messing with the index inside the for loop!) I thought it might be a problem with the variable type of i, since I think values stored as integers have a relatively small limit, but it looked like i was stored as type long, which should be able to hold much larger than 50,000.
Does anyone have any suggestions? Your help is much appreciated!
-S
I consider myself typically a confident Matlab user. But I have encountered a new problem that I have no idea how to solve, so I'm hoping I can find some help.
I have set up a for loop in my code to the effect of
for i = 1:n
if MyArray(i,1) < some value
perform other calculations
end
end
The code runs fine for small values of n. But, when I have a very large n (somewhere near 50,000), I get an error message:
? Attempted to access MyArray(NaN,1); index must be a positive integer or logical.
And, checking on the value of the index i, it has become NaN.
I don't understand how this is possible as Matlab should be incrementing i itself within the for loop. (I promise I'm not messing with the index inside the for loop!) I thought it might be a problem with the variable type of i, since I think values stored as integers have a relatively small limit, but it looked like i was stored as type long, which should be able to hold much larger than 50,000.
Does anyone have any suggestions? Your help is much appreciated!
-S