How do you indicate a line between a user and a GPS satellite?

3 visualizzazioni (ultimi 30 giorni)
The distance between the satellite and the user was obtained, but it was obtained with the ECEF coordinate system.
If you use ecef2enu, a function that changes the distance to the ENU coordinate system, errors continue to occur. I am curious about the solution, and furthermore, I want to use the unit vector to reduce the distance and then visualize the satellite-user distance.
receiverLat = 37.498759;
receiverLon = 127.027487;
receiverAlt = 0;
t = datetime('now', 'TimeZone', 'Local');
[satPos, ~] = gnssconstellation(t);
wgs84 = wgs84Ellipsoid('meters');
[recX, recY, recZ] = geodetic2ecef(wgs84, receiverLat, receiverLon, receiverAlt);
distances = zeros(size(satPos, 1), 1);
for i = 1:size(satPos, 1)
satX = satPos(i, 1);
satY = satPos(i, 2);
satZ = satPos(i, 3);
distances(i) = sqrt((satX - recX)^2 + (satY - recY)^2 + (satZ - recZ)^2);
end
disp('Satellite location:');
disp(satPos);
disp('Receiver location:');
disp([recX, recY, recZ]);
disp('Satellite-Receiver distances:');
disp(distances);

Risposta accettata

William Rose
William Rose il 23 Gen 2025
Why do you think there are errors?
I modified your script slightly to display the receiver radius from Earth center, and the distance from receiver to the nearest and farthest satellites, and the difference between the nearest and farthest distances. One would expect the difference betwen nearest and farthest to be on the order of 2 Earth radii (~2 x 6.37e6 m). It is.
receiverLat = 37.498759;
receiverLon = 127.027487;
receiverAlt = 0;
t = datetime('now', 'TimeZone', 'Local');
[satPos, ~] = gnssconstellation(t);
wgs84 = wgs84Ellipsoid('meters');
[recX, recY, recZ] = geodetic2ecef(wgs84, receiverLat, receiverLon, receiverAlt);
distances = zeros(size(satPos, 1), 1);
for i = 1:size(satPos, 1)
satX = satPos(i, 1);
satY = satPos(i, 2);
satZ = satPos(i, 3);
distances(i) = sqrt((satX - recX)^2 + (satY - recY)^2 + (satZ - recZ)^2);
end
%disp('Satellite location:');
%disp(satPos);
fprintf('Receiver location: %.3e, %.3e, %.3e m.\n',recX,recY,recZ);
Receiver location: -3.051e+06, 4.045e+06, 3.861e+06 m.
fprintf('Receiver radius from center = %.3e m.\n',sqrt(recX^2+recY^2+recZ^2));
Receiver radius from center = 6.370e+06 m.
%disp('Satellite-Receiver distances:');
fprintf('Closest=%.2e, farthest=%.2e, difference=%.2e.\n',...
min(distances),max(distances),max(distances)-min(distances));
Closest=2.02e+07, farthest=3.27e+07, difference=1.25e+07.
  5 Commenti

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Earth and Planetary Science in Help Center e File Exchange

Prodotti


Release

R2024b

Community Treasure Hunt

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

Start Hunting!

Translated by