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);
0 个评论
采纳的回答
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);
fprintf('Receiver radius from center = %.3e m.\n',sqrt(recX^2+recY^2+recZ^2));
%disp('Satellite-Receiver distances:');
fprintf('Closest=%.2e, farthest=%.2e, difference=%.2e.\n',...
min(distances),max(distances),max(distances)-min(distances));
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Earth and Planetary Science 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!