Sequential reading of an array using loop

2 Ansichten (letzte 30 Tage)
ShahZahid
ShahZahid am 16 Dez. 2020
Beantwortet: Ameer Hamza am 16 Dez. 2020
Hello!!
How to sequentially read arrays and apply an operation. e.g. I am having two arrays of Latitudes,Longitudes, and Altitudes.
lat=[27.692612,27.690227,27.696509]
lon=[85.342982,85.342576,85.33567]
alt=[100,95,90]
Using a loop, I want to apply anoperation to every entry of lat, lon, alt e.g. converting these latitudes, longitudes, altitudes to ECEF using "lla2ecf" function
[X1,Y1,Z1]=lla2ecef(Lat(1),lon(1),alt(1));
[X2,Y2,Z2]=lla2ecef(Lat(2),lon(2),alt(1));
.
.
.
[Xn,Yn,Zn]=lla2ecef(Lat(end),lon(end),alt(end));

Antworten (1)

Ameer Hamza
Ameer Hamza am 16 Dez. 2020
You can use arrayfun(), which is essentially an implicit for-loop
lat=[27.692612,27.690227,27.696509]
lon=[85.342982,85.342576,85.33567]
alt=[100,95,90]
[X, Y, Z] = arrayfun(@lla2ecef, lat, lon, alt)

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by