Random Lat lon in a radious
4 views (last 30 days)
Show older comments
Rakibul Islam Rony on 3 May 2019
Edited: Rakibul Islam Rony on 3 May 2019
Hi Everyone, i need your help :(
I am trying to generate some random lat lon within a radious, say 200m from a given lat lon. I have geolocations in degrees, which i coverted to radian to calculate the distance.
I am trying the below code, but it is not giving correct answers.
R = 0.2 ; % radius of circle
H_lat = xUE0
H_lon = yUE0
earthRadiusKm = 6371;
plot (xUE,yUE )
d_lat = xUE-H_lat ;
d_lon = yUE-H_lon ;
a = (sin (d_lat/2))^2 + (sin(d_lon/2))^2 * cos (H_lat)*cos(xUE);
c = 2*atan2( sqrt(a), sqrt(1-a) ) ;
d = earthRadiusKm * c ;
H_distance = d*1000 ;
Rik on 3 May 2019
This time I edited your question for you. Next time, please use the tools explained on this page to make your question more readable.
Find more on Random Number Generation in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!