I have GPS NMEA (National Marine Electronics Association) data that I collected being stationary and I can see the displacement of 4 meters just by looking at GPX data uploaded to google maps.
I am trying to see this 4 meters by math. I am using Matlab where I read the data in geodetic degrees and used a function to translate it to ECEF in XYZ. I have done that for both the measurement of GPS and my true location and subtracted both in XYZ.
The result is showing a difference of 312 in X-axis and 60 in Y-axis, instead, I was expecting around 4 for both.
Below is the code I used for Geodetic DD conversion to ECEF XYZ:
lat = lat/180*pi; %converting to radians long = long/180*pi; %converting to radians a = 6378137.0; % earth semimajor axis in meters f = 1/298.257223563; % reciprocal flattening e2 = 2*f -f^2; % eccentricity squared chi = sqrt(1-e2*(sin(lat)).^2); X = (a./chi +h).*cos(lat).*cos(long); Y = (a./chi +h).*cos(lat).*sin(long); Z = (a*(1-e2)./chi + h).*sin(lat);
example of latitude/x-axis allocation:
GPSDD(1,1) = 50.682201667 >> XYZmeas(1) = 3976168.03008252
TrueDD(1) = 50.682214 >> XTZtrue(1) = 3975855.46252364
XYZmeas(1) - XTZtrue(1) = 312.567558876704
Did I miss anything or is there any suggestion what would be my mistake?