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: index out of bounds error
Replies: 7   Last Post: Mar 8, 2013 1:13 AM

 Messages: [ Previous | Next ]
 nur Posts: 16 Registered: 1/3/08
index out of bounds error
Posted: Feb 28, 2013 11:34 PM

Hi,
I'm doing a research on crowd behavior analysis.I've a problem with the coding below;

clear; clc; close all;
mx=45; my=45;
X=10;
d=zeros(mx,my); dx=zeros(mx,my); dy=zeros(mx,my);

Lx=10;Ly=10;
hx=Lx/(mx-1); hy=Ly/(my-1);
x=0:Lx/(mx-1):Lx; y=0:Ly/(my-1):Ly;

N_Obst=2; xx=[X]; yy=[X]; rr=[X];

d(1:mx, 1:my)=Lx+Ly;
for i=1:1:mx
x(i)=(i-1)*hx;
for j=1:1:my
y(j)=(j-1)*hy;

for n=1:1:N_Obst
dtemp=sqrt((xx(n)-x(i))^2+(yy(n)-y(j))^2)-rr(n);
% dtemp=sqrt((x(n)-x(i))^2+(y(n)-y(j))^2);
if dtemp<d(i,j); d(i,j)=dtemp; end
end

Error => Attempted to access xx(2); index out of bounds because numel(xx)=1.

Anyone can help me solve this problem?

Date Subject Author
2/28/13 nur
2/28/13 Nasser Abbasi
2/28/13 nur
3/1/13 Nasser Abbasi
3/1/13 nur
3/1/13 Nasser Abbasi
3/7/13 nur
3/8/13 Nasser Abbasi