distance

Distance Between Two Points in Matlab

丶灬走出姿态 提交于 2019-12-01 20:14:09
I have 2 vectors one is 200*2 in dimension and other is 3*2.All of them are points in a cartesian coordinate system. I want to calculate the distance between the first 200 and the other 3 points and store them in a vector. I'm using a function like this; for i=1:cur for j=1:200 L(j,i)=sqrt(square(P2(i,1)-C(j,1))+square(P2(i,2)-C(j,2))) end end where cur is 3 , P2 being the 3*2 vector and C being the 200*2.Now the results i get are completely wrong but I cannot figure out the problem in that. Any help would be good , if there is another way to compute it i would appreciate.By the way for more

Wrong Euclidean distance H2O calculations R

元气小坏坏 提交于 2019-12-01 19:43:29
I am using H2O with R to calculate the euclidean distance between 2 data.frames: set.seed(121) #create the data df1<-data.frame(matrix(rnorm(1000),ncol=10)) df2<-data.frame(matrix(rnorm(300),ncol=10)) #init h2o h2o.init() #transform to h2o df1.h<-as.h2o(df1) df2.h<-as.h2o(df2) if I use normal calculations, i.e. the first row: distance1<-sqrt(sum((df1[1,]-df2[1,])^2)) And If I use the H2O library: distance.h2o<-h2o.distance(df1.h[1,],df2.h[1,],"l2") print(distance1) print(distance.h2o) The distance1 and distance.h2o are not the same. Does anybody knows why? Thanks!! It seems as if h2o.distance

Symfony2, Doctrine search and order by distance

邮差的信 提交于 2019-12-01 18:33:35
I have a database of places which I store the latitude and longitude for. I want to query the database to find all places within a radius ( $requestedDistance ) of a specific latitude ( $latitude ) and longitude ( $longitude ). The below query works and returns only those places within this radius, however how would I order them by distance so the closest is first? In the past, using raw SQL I have done the calculation within the SELECT statement and set it as 'distance' and then used HAVING distance < $requestedDistance ORDER BY distance , however I'm not sure how to add the calculation to

how to find wifi signal direction of another device in android?

China☆狼群 提交于 2019-12-01 17:29:02
I am using my android phone as Access Point. Now I want to find the distance and direction of the wifi devices connected with my phone. Please help me through suitable example and code. Thanks in advance. I downloaded Wifi Radar that you mentioned and tried it. There's an important step there - it asks you to rotate on the spot for a bit while holding the device to your body. So my guess is that it uses the internal compass to figure out which direction you're pointing to, and then measures the signal. When the signal gets stronger, it figures that you're pointing toward the AP. Since the app

calculate distance

寵の児 提交于 2019-12-01 13:32:13
问题 i am designing a recruitment database, and i need it to perform several tasks that all involve integrating a way of calculating distance: 1) calculate the distance the candidate lives from the client? 2) calculate the clients within a radius of the candidates available for work on any given day? 3) calculating the number of candidates with the correct qualifications for the vacancy within a radius of the client. as you can see i need to calculate the distance in 2 main ways 1) radius 2) as

K-Medoids / K-Means Algorithm. Data point with the equal distances between two or more cluster representatives

拜拜、爱过 提交于 2019-12-01 12:58:27
I have been researching and studying about partition-based clustering algorithms like K-means and K-Medoids. I have learned that K-medoids is more robust to outliers compared to K-means. However I am curious on what will happen if during the assigning of data points, two or more cluster representatives have the same distance on a data point. Which cluster will you assign the data point? Will the assignment of the data point to a cluster greatly affect the clustering results? To prevent bad things from happening (infinite loops etc.) always prefer the cluster the point already is assigned to

How to track distance via GPS on Android?

那年仲夏 提交于 2019-12-01 12:13:12
How would I go about tracking the distance a user travels? I don't necessarily care about storing waypoints, although that may be necessary to calculate distance anyway. So far, I am creating a LocationManager and regsitering an onLocationChanged listener, and then calculating the raw distance between two points when the listener fires. The problem here is that if I leave the app sit still on a desk for 10, 15 minutes, it will say I have traveled .5 miles. How should I go about checking for accuracy and determining which points to use? Or, even better - is there an SDK or .jar I can just

find Distance in kilometers in Android using google places Api

血红的双手。 提交于 2019-12-01 11:59:21
I want display the two places distance in kilometers for that I write the following code: hyd(17.38,78.48) eluru(16.7,81.1) private String getDistance(double lat1, double lat2, double lon1, double lon2) { double Radius = 6371; double dLat = Math.toRadians(lat2 - lat1); double dLon = Math.toRadians(lon2 - lon1); double a = Math.sin(dLat / 5) * Math.sin(dLat / 5) + Math.cos(Math.toRadians(lat1)) * Math.cos(Math.toRadians(lat2)) * Math.sin(dLon / 5) * Math.sin(dLon / 5); double c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a)); double km = Radius * c; String kms=Double.toString(km); return kms;

Python:- Given a list of tuple coordinates, find the nearest coord to a specified coord (Google Maps Coords)) [duplicate]

牧云@^-^@ 提交于 2019-12-01 11:17:06
问题 This question already has answers here : from list of tuples, get tuple closest to a given value (3 answers) Closed 4 years ago . I'm Using Python and done something with the following, Given a list of tuple coordinates, find the nearest coord to a specified coord (Google Maps Coords)). But not accurate nearest coordinates compared with google maps on my code. Please help me. Here is my code def find_coords(c, l): tmp_list = [] (x,y) = l[0] for (a,b) in l[1:]: if (x-c[0])**2 + (y-c[1])**2 >

how to extract intragroup and intergroup distances from a distance matrix? in R

陌路散爱 提交于 2019-12-01 10:55:45
I have this dataset: values<-c(0.002,0.3,0.4,0.005,0.6,0.2,0.001,0.002,0.3,0.01) codes<-c("A_1","A_2","A_3","B_1","B_2","B_3","B_4","C_1","C_2","C_3") names(values)<-codes In the codes, the letter indicates a group and the number a case within each group. Therefore I have three groups and 3 to 4 cases in each group (the actual dataset is much larger but this is a subset). Then I calculate the distance matrix: dist(values)->dist.m Now I would like to convert the dist.m in a dataset with two columns: one containing the distances "inside" all groups (distance between A_1 and A_2, between B_2 and