Problem with enu2geodetic() Function
Ältere Kommentare anzeigen
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 Kommentare
Image Analyst
am 4 Aug. 2023
The only thing I can think of is that one or more of
- spheroid, x, y, or z or
- x(i), y(i), z(i), latCenter, lonCenter, altCenter, wgs84Ellipsoid
must have changed from the time you ran it yesterday.
Alex Lipp
am 7 Aug. 2023
Alex Lipp
am 7 Aug. 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.
Antworten (0)
Kategorien
Mehr zu Geographic Coordinate Reference Systems finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!