lat1=15.850388;
lon1=74.498652;
lat2=15.850254;
lon2=74.498539;
lat3=15.850404;
lon3=74.498500;
R = 6371; % Earth's radius in km
delta_lat = lat2 - lat1; % difference in latitude
%fprintf(' %d \n',delta_lat);
delta_lon = lon2 - lon1; % difference in longitude
%fprintf(' %d \n',delta_lon);
a = sin(delta_lat/2)* sin(delta_lat/2) + cos(lat1) * cos(lat2) * sin(delta_lon/2)* sin(delta_lon/2);
c = 2 * atan2(sqrt(a), sqrt(1-a));
km = R * c;
fprintf(' %d \n',km);
delta_lat1 = lat3 – lat2;
delta_lon1 = lon3 – lon2;
a1 = sin(delta_lat1/2)* sin(delta_lat1/2) + cos(lat2) * cos(lat3) * sin(delta_lon1/2)* sin(delta_lon1/2);
c1 = 2 * atan2(sqrt(a1), sqrt(1-a1));
km1 = R * c1;
fprintf(' %d \n',km1);