You may want to seethe vectorization link here. I tried doing the vectorization for you, but just got confused in the loops. Since you understand your program better than I do, you might be able to find a way after reading the info in this link.
hei, thanks for this answer. i am not sure how this works, since i dont calculate one value.
the first loop (i). chooses the point (CR) with the radius. the second loop checks every point (P) whether it is within this circle or not. if yes, the counter goes one up.
ill try to explain the loops: loop 1 (i = 1:k), defines the point in the point cloud with a certain radius. and each point in the point cloud has to be compared to all others, whether the point is within the distance or not.
loop 2 (j = 1 : k), chooses one point (P) after another and checks whether this point lies within the radius of the first point (CR) if yes, the counter goes up.
Allocate the 4th column of data in advance of the loops. Then, data has 3 (or 4) columns so what do you think you're getting for CR and P when you refer to data(i,1:2)? What's the third index? Why are you not specifying it?
Right - nevermind - I was thinking 3D in my head, but you have a 2D matrix. Have you tried the run and time button? I don't have isPointInCircle() so I can't really help a lot.
i tried this and it went faster. unfortunatly only one second. - the problem is, that i need to get rid of unnecessary loops. so that points wich are far out of range are not going to be tested again. or i need a method, to skip the points in the second loop, when they have been tested in the first loop.
Generated 14-Sep-2013 18:13:12 using cpu time.
Function NameCallsTotal TimeSelf Time*Total Time Plot