Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: Out of bound Error
Replies: 5   Last Post: Feb 20, 2013 1:18 PM

 Messages: [ Previous | Next ]
 dpb Posts: 9,850 Registered: 6/7/07
Re: Out of bound Error
Posted: Feb 20, 2013 10:51 AM

On 2/20/2013 9:21 AM, Jerome wrote:
> I get the following error and I am unsure how to fix it. I tried to edit
> the rows and cols but it seems not to work. Does anyone know a quick fix
> to this problem:
>
> ??? Attempted to access cyy(1,901); index out of bounds because
> size(cyy)=[700,900].
>
> Error in ==> snake at 31
> eterm(i,j) = (cyy(i,j)*cx(i,j)*cx(i,j) -2
> *cxy(i,j)*cx(i,j)*cy(i,j) +
> cxx(i,j)*cy(i,j)*cy(i,j))/((1+cx(i,j)*cx(i,j) +
> cy(i,j)*cy(i,j))^1.5);
>
>

...

> [row col] = size(image);
...

> for i = 1:row
> for j= 1:col-1
> eterm(i,j) = (cyy(i,j)*cx(i,j)*cx(i,j)...
> end
> end

What does

size(image)

return? (Remove the ';' and rerun or use debug to stop and look)

col must be >901 for the loop index j to be 901. Or, of course, it's
possible the code that is being executed isn't what you're looking at
and have posted but a cached or aliased copy.

which snake % see where the actually-referenced copy is
clear snake % clear any cached copies

--

Date Subject Author
2/20/13 Jerome
2/20/13 dpb
2/20/13 Jerome
2/20/13 dpb
2/20/13 Jerome
2/20/13 Jerome