I write a script to check the lattice point the (vector pts), which is in the sphere centered at certain points(x and y) which is on the top side of the lattice. But this code works so slow which contains a lot of for loop and square root operation. Can you help me to fix this problem?
pts1 = 
for i = 1:1:length(x)
for j = 1:1:length(pts)
dist = (x(i)-pts(j,1))^2+(y(i)-pts(j,2))^2+(pts(j,3))^2;
if dist <= vt^2
a = [pts(j,1) pts(j,2) -pts(j,3)];
pts1 = [pts1;a];