How do you indicate a line between a user and a GPS satellite?
조회 수: 3 (최근 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));
댓글 수: 5
추가 답변 (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!