Problem with enu2geodetic() Function

DISCLAIMER: I work in a secure environment, so I am unable to share any code. I will try my best to explain the issue as specifically as possible.
ISSUE: When I run enu2geodetic() using the proper arguments and the 'wgs84Ellipsoid' object, I get the following error:
*******************************************************************************************************************************************************************
Index exceeds the number of array elements. Index must not exceed 1.
Error in ecef2geodetic (line 74)
e2 = ellipsoid(2) ^ 2; % Square of first eccentricity
Error in enu2geodetic (line 35)
[lat, lon, h] = ecef2geodetic(spheroid, x, y, z);
Error in [REDACTED] (line [REDACTED])
[lat(i), lon(i), alt(i)] = enu2geodetic(x(i), y(i), z(i), latCenter, lonCenter, altCenter, wgs84Ellipsoid);
*******************************************************************************************************************************************************************
The problem is that inside ecef2geodetic(), the 'ellipsoid' variable is just a single value (1-element array), so it errors when ellipsoid(2) is referenced.
My code worked perfectly fine as of yesterday. I did not make any changes to the code or my environment prior to today where I am now getting the error. It makes me wonder if MathWorks changed something internally.
Any and all insight is greatly appreciated.

4 commentaires

Image Analyst
Image Analyst le 4 Août 2023
The only thing I can think of is that one or more of
  1. spheroid, x, y, or z or
  2. x(i), y(i), z(i), latCenter, lonCenter, altCenter, wgs84Ellipsoid
must have changed from the time you ran it yesterday.
Alex Lipp
Alex Lipp le 7 Août 2023
Image Analyst,
I run the command through a loop with thousands of points, but my error is occuring on the first iteration of the loop, using points that I have used before with no issues.
Alex Lipp
Alex Lipp le 7 Août 2023
Ok, so I found something weird in my latest debugging attempt.
enu2geodetic() calls the function ecef2geodetic(spheroid, x, y, z). At this point, spheroid is as it should be.
However, when ecef2geodetic() is called, it is assuming the argument signature (x,y,z, ellipsoid) instead of (ellipsoid, x,y,z), so the variable ellipsoid takes the value of what x should be and the variable x is taking the value of what ellipsoid should be.
How do I force enu2geodetic() to call the version of ecef2geodetic() using the correct argument signature?
Jim Riggs
Jim Riggs le 7 Août 2023
Modifié(e) : Jim Riggs le 8 Août 2023
I see that wgs84Ellipsoid is a built-in function in the Mapping toolbox. Make sure that you are not ghosting this function by creating a variable with the same name (it can be that MATLAB is interpreting the reference as a variable, rather than a function due to some syntax usage). Try E = wgs84Ellipsoid and see what you get for E. If it's not a referenceEllipsoid object, then that is the problem.

Connectez-vous pour commenter.

Réponses (0)

Produits

Version

R2021b

Question posée :

le 4 Août 2023

Modifié(e) :

le 8 Août 2023

Community Treasure Hunt

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

Start Hunting!

Translated by