Motion

Published on March 2017 | Categories: Documents | Downloads: 43 | Comments: 0 | Views: 238
of 1
Download PDF   Embed   Report

Comments

Content

x1=rand;
y1=rand;
x2=rand;
y2=rand;
nstep=300;
for i=0:nstep
dx1=(rand*2-1)/10;
dy1=(rand*2-1)/10;
x1=x1+dx1;
y1=y1+dy1;
i=i+1;
dx2=(rand*2-1)/10;
dy2=(rand*2-1)/10;
x2=x2+dx2;
y2=y2+dy2;
i=i+1;
if x1<0 || x1>1
x1=rand;
end
if y1<0 || y1>1
y1=rand;
end
if x2<0 || x2>1
x2=rand;
end
if y2<0 || y2>1
y2=rand;
end
plot(x1,y1,'ob',x2,y2,'ob');axis([0 1 0 1]);
pause(0.1)
if sqrt((x1-x2)^2+(y1-y2)^2)<=0.1
disp('the particles have reacted')
break
end
end

Sponsor Documents

Or use your account on DocShare.tips

Hide

Forgot your password?

Or register your new account on DocShare.tips

Hide

Lost your password? Please enter your email address. You will receive a link to create a new password.

Back to log-in

Close