This question is closed. Reopen it to edit or answer.
Index in position 1 is invalid. Array indices must be positive integers or logical values.
2 views (last 30 days)
I am getting the following error: Index in position 1 is invalid. Array indices must be positive integers or logical values.
Can anybody tell me how can I fix it?
The error in this line:
And my code is:
xm=-13; ym=-13; th=pi/2;
rr=1; %Robot radius
n=4; %Number of sensors
w=100*eps; % 100*eps because eps alone is too small, so causes division by zero problem
while m(xm,ym)==0 %if the location not occupied
xm=xm+r*cos(th); %corridnates(x,y) for the robot location
ym=ym+r*sin(th); %r is length(r)
if m(xm,ym)~=0 %if the location occupied
mesh(xm,ym,m); view(0, 90); axis image; hold on;
Paul Hoffrichter on 19 Apr 2021
Would be very useful if you are able to post a minimal program exhibiting the error that we could run. In the debugger, set the Run button to "Pause on Error". When the program breaks at the error, check that xm and ym are scalars, and check that they are both greater than 0.