help-octave
[Top][All Lists]

## Re: What is error(19) or error(15): out of bound(1)...how to resolve?

 From: James Sherman Jr. Subject: Re: What is error(19) or error(15): out of bound(1)...how to resolve? Date: Sat, 27 Oct 2018 17:11:46 -0400

On Sat, Oct 27, 2018 at 4:36 PM Satyaballi <address@hidden> wrote:
please tell me...m solving an optimization problem with inequality
constraints.  The error m getting while running my code is : "error: x(15):
out of bound 1"

please let me know...what is the error and how to resolve this.

--
Sent from: http://octave.1599824.n4.nabble.com/Octave-General-f1599825.html

Hi Satyaballi,

Out of bounds errors occur when you're trying to access a vector with an index that is larger than its length.  For example,
>> x = zeros(1,10);
>> x(12)
error: x(12): out of bound 10
>>

So, from the error you gave, on line 44 of the g function, the vector x (which has size 1) is trying to be accessed by an index of 15.  Usually in these cases, if I can't figure out why this is happening, I either put a breakpoint at that line and see what the value of the offending vector (or index) or place an if/endif statement to check to see if the size of x is 1 (in this case) since you obviously are assuming that it is longer than that.

Hope this helps,
James Sherman Jr.