how to express i=i+1 in mathlab

i'm working to write a code for the attached file, but it doesn't work. can someone help me on this? here are the code that i have wrote:
x0=input('x0= ');
y0=input('y0= ');
x1=input('x1= ');
y1=input('y1= ');
dL=input('dL= ')
f(1)=90;
s=-atan((y1-y0)/(x1-x0));
while(y0>y1)
if (f[i]>=s)
x[i+1]=x[i]+(dL.*cos(f[i]-3))
y[i+1]=y[i]+(dL.*sin(f[i]-3))
else
x[i+1]=x[i]+(dL.*cos(f[i]+3))
y[i+1]=y[i]+(dL.*sin(f[i]+3))
end
f[i+1]=-atan((y[i+1]-y[i])/(x[i+1]-x[i]));
if (y0-y1)^2+(x0-x1)^2>(dL)^2
i=i+1;
end
end
disp(x[i+1]);
disp(y[i+1]);

Answers (1)

You need to set i equal to 1 before you start the while loop. And you need to make x0 be x(1), y0 be y(1), x1 be x(2), and y1 be y(2). And instead of
disp(x[i+1]);
disp(y[i+1]);
simply put
x
y
Even after all that, there's still stuff wrong with it but nothing that can't be figured out after you look at this: http://blogs.mathworks.com/videos/2012/07/03/debugging-in-matlab/

Categories

Tags

No tags entered yet.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!