How to ensure that all values are not equal when using the ecef2enu function
10 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
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 Commenti
Risposta accettata
Ryan Salvo
il 31 Mar 2025
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
Più risposte (1)
KALYAN ACHARJYA
il 30 Mar 2025
Modificato: KALYAN ACHARJYA
il 30 Mar 2025
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);
Vedere anche
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!