Index out of range

User ForumIndex out of range
Hany Latif asked 3 years ago

I am trying to run some code on my data.  GAUSS reports the error message below.

error G0058 : Index out of range

Does anyone know what this means?

Thank you!

1 Answers
Aptech Staff answered 3 years ago

Index out of range means that the code is trying to access a matrix or vector outside of its bounds. For example:

x = rndn(5, 1);
y = x[6, 1];

would cause this error, because it is trying to access the 6th element out of a total of 5. This can also happen if the value you using as an index is an Infinity, Nan or missing value. For example:

idx = 1/0;
x = ones(5, 1);
y = x[idx];

would also return this error.