Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

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


Math Forum » Discussions » Software » comp.soft-sys.matlab

Topic: index out of bounds
Replies: 3   Last Post: Dec 28, 2009 11:58 AM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Chua Ivue

Posts: 4
Registered: 12/1/09
index out of bounds
Posted: Dec 28, 2009 7:40 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

n=[0 1;1 1;1 0;1 -1;0 -1;-1 -1;-1 0;-1 1];
flag=1;
cc=[];
[x y]=find(crop==1);
x=min(x);
imx=crop(x,:);
y=min(find(imx==1));
first=[x y];
dir=7;
while flag==1
tt=zeros(1,8);
ndir=mod(dir+7-mod(dir,2),8);

for i=0:7
j=mod(ndir+i,8)+1;

tt(i+1)=crop(x+n(j,1),y+n(j,2));
end

d=min(find(tt==1));


dir=mod(ndir+d-1,8);

cc=[cc,dir];

x=x+n(dir+1,1);
y=y+n(dir+1,2);




if x==first(1) & y==first(2)
flag=0;
end
end
*******************************
error message i got:
Attempted to access crop(175,193); index out of bounds because size(crop)=[174,266].

Error in ==> tt(i+1)=crop(x+n(j,1),y+n(j,2));
*********************************
can anyone tell me why?? <URGENT>
Appreciate your help!



Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.