How can I obtain the distance between two tracks of 3d GPS coordinates?
17 次查看(过去 30 天)
显示 更早的评论
I have two matrices A and B with GPS track data points (longitude, latitude, altitude). However they do not have the same size (rows). I am looking for a way to obtain a matrix which contains the distance in 3d space between the two tracks as well as a way to obtain the distance component of each axis respectively (lon, lat, alt), namely the distance from each data point in A to it's closest data point in B.
0 个评论
采纳的回答
Adit Alware
2022-5-25
Hi Nicolas,
I understand that you have two matrices A and B with and 3 columns(lat, long, alt) and different number of rows.
To obtain the distance between coordinates with given latitude and longitude, you may use the "distance" function from Mapping Toolbox.
dist = distance(lat1,lon1,lat2,lon2)
The output distance will be in degrees. To convert it into km or miles you may use:
dist = deg2km(dist) % convert to kilo meters
dist = deg2nm(dist) % convert to nautical miles
To obtain the final distance accomodating altitude you may calculate the folllowing :
finaldist = sqrt(dist^2 + (alt1-alt2)^2)
Suppose that we have C number of rows in A and D number of rows in B.
Now you may run a nested for loop in a manner such that they compute a matrix R of size C X D where each entry (i,j) represents the distance between ith coordinate of A and jth coordinate of B.
Now for example, to calculate the distance component of a coordinate for latitude axis, you may find the distance between point (lat,long,alt) and (lat,0,0).
After that you may calculate the minimum distance of point in A from all the points in B using the "min" function as follows:
minDist = min(R')
The output will be a row vector where ith entry will represent minimum distance of ith coordinate in A from all the coordinates in B.
Thanks
0 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Coordinate Systems 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!