How to ensure that all values are not equal when using the ecef2enu function
10 次查看(过去 30 天)
显示 更早的评论
I'm doing coordinate system transformation using the ecef2enu function. But for some reason, all three E, N, and U values are the same. I wonder why. How can I modify it to get the exact value?
Isn't it normal for the 1, 2, 3 matrices to have different values? Is there something wrong with my code?

currTime = gnss.SensorModel.InitialTime;
setup(scene)
wgs84 = wgs84Ellipsoid('meter');
while scene.IsRunning
[~,~,p,satPos,status] = gnss.read ();
allSatPos = gnssconstellation(currTime); % ecef
currTime = currTime + seconds(1/scene.UpdateRate);
[~,trueRecPos] = plat.read; % lla
trueRecPos_ecef = lla2ecef(trueRecPos); % uav ecef
[az,el] = lookangles(trueRecPos,satPos,gnss.SensorModel.MaskAngle);
nsat = length(satPos(:,1));
enu_sat = zeros(nsat,3);
for k = 1:1:nsat
enu_sat(k,:) = ecef2enu(satPos(k,1),satPos(k,2),satPos(k,3),trueRecPos(1),trueRecPos(2),trueRecPos(3),wgs84);
end
temp=1;
unit_sat = normalize(enu_sat,'norm',1);
target_z = 500;
scale_factors = target_z ./ unit_sat(:,3);
unit_sat_scaled = unit_sat .* scale_factors;
end
0 个评论
采纳的回答
Ryan Salvo
2025-3-31
The ecef2enu function returns three output arguments, but you are setting all three columns of the enu_sat variable with only the first output argument. Update the for-loop to:
for k = 1:1:nsat
[enu_sat(k,1),enu_sat(k,2),enu_sat(k,3)] = ecef2enu(satPos(k,1),satPos(k,2),satPos(k,3),trueRecPos_lla(1),trueRecPos_lla(2),trueRecPos_lla(3),wgs84);
end
更多回答(1 个)
KALYAN ACHARJYA
2025-3-30
编辑:KALYAN ACHARJYA
2025-3-30
As there may be multiple reasons, I don't have the complete data file and am unable to reproduce the issue. Please give it a try converting Earth-Centered Earth-Fixed (ECEF) coordinates to geodetic coordinates first might help.
trueRecPos_lla = ecef2lla(trueRecPos_ecef);
enu_sat(k,:) = ecef2enu(satPos(k,1), satPos(k,2), satPos(k,3), trueRecPos_lla(1), trueRecPos_lla(2), trueRecPos_lla(3), wgs84);
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!