How to calculate the slope from geopraphical coordinates?

조회 수: 117(최근 30일)
Hi all,
I have installed a GPS logger on a vehicle, so I have extracted the geographcal coordinates in degree (longitude, latitude and elevation). I need to calculate the slope encountered by the vehicle. I came up with the following code, that is far from being good as you can see in the attached plot. How may I improve the results?
wgs84 = wgs84Ellipsoid('meters');
[gpsx,gpsy,gpsz] = geodetic2ecef(wgs84,Latitude,Longitude,Altitude);
slope=atand(diff(gpsz)./sqrt(diff(gpsx).^2+diff(gpsy).^2));
Thank you.
Best regards.

채택된 답변

Jim Riggs
Jim Riggs 2020년 1월 19일
편집: Jim Riggs 2020년 1월 19일
First of all, you should consider the relationship between the WGS84 lat/lon/alt and the ECEF frame. Altitude is perpendicular to the reference ellipsoid, so it is effectively parallel to "down". I would assume that if you want to know the slope encounrered by a vehicle, that implies the rate of change of "down" over the horizontal displacement. So when you tranform your data to ECEF, you lose the "down" reference.
Matlab Answers 20200118a.JPG
Rather, you should be working in a local level frame, such as North/East/Down (NED).
You can transform ECEF to NED using;
In this (NED) frame, X points to the north, Y points east, and Z points down (i.e positive z is down) . Now if you calculate delta Z over the X-Y distance (in the NED frame), it should come out as the parameter you are seeking; the change in height over the change in horizontal distance. This would be the tangent of the local slope angle.
  댓글 수: 3
Jeremy Salerno
Jeremy Salerno 2022년 6월 21일
If you have lat/lon in degrees with height in meters, are you still able to use the geodetic2ned or geodetic2enu the same way? Can my input be in lat, lon for x, y and meters for z, or do conversions need to be made beforehand?

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

추가 답변(0개)

범주

Find more on Vehicle Scenarios in Help Center and File Exchange

태그

제품


릴리스

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by