Random Lat lon in a radious

조회 수: 1 (최근 30일)
Rakibul Islam Rony
Rakibul Islam Rony 2019년 5월 3일
편집: Rakibul Islam Rony 2019년 5월 3일
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
xUE0=35.3333888900000*pi/180 %radin
yUE0=25.1055555600000*pi/180
angle=-pi:0.01:pi;
angl=angle(randperm(numel(angle),1));
r=rand(1,1)*R;
xUE=r.*cos(angl)+xUE0;
yUE=r.*sin(angl)+yUE0;
H_lat = xUE0
H_lon = yUE0
earthRadiusKm = 6371;
%calculating distance
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 ;
  댓글 수: 1
Rik
Rik 2019년 5월 3일
This time I edited your question for you. Next time, please use the tools explained on this page to make your question more readable.

댓글을 달려면 로그인하십시오.

답변 (0개)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by