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

4 次查看(过去 30 天)
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);

采纳的回答

William Rose
William Rose 2025-1-23
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 个评论

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Earth and Planetary Science 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by