-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathChr_to_Chr_Rep.m
More file actions
15 lines (14 loc) · 852 Bytes
/
Copy pathChr_to_Chr_Rep.m
File metadata and controls
15 lines (14 loc) · 852 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
function[F_repulsive_chr]=Chr_to_Chr_Rep(n_chr,X_chr,C,L_chr);
F_repulsive_chr=zeros(2,n_chr);
for i=1:n_chr
for j=(i+1):n_chr
distChrtoChr=sqrt((X_chr(1,j)-X_chr(1,i)).^2+(X_chr(2,j)-X_chr(2,i)).^2);
if(distChrtoChr<2*L_chr)
ChrtoChrvec=[(X_chr(1,j)-X_chr(1,i))/distChrtoChr; (X_chr(2,j)-X_chr(2,i))/distChrtoChr];
F_repulsive_chr(1,i)=F_repulsive_chr(1,i)+(ChrtoChrvec(1)*C)/(1+distChrtoChr); %letting the constant "C" be 1 in the numerator
F_repulsive_chr(2,i)=F_repulsive_chr(2,i)+(ChrtoChrvec(2)*C)/(1+distChrtoChr);
F_repulsive_chr(1,j)=F_repulsive_chr(1,j)-(ChrtoChrvec(1)*C)/(1+distChrtoChr); %letting the constant "C" be 1 in the numerator
F_repulsive_chr(2,j)=F_repulsive_chr(2,j)-(ChrtoChrvec(2)*C)/(1+distChrtoChr);
end
end
end