Sequential reading of an array using loop

1 回表示 (過去 30 日間)
ShahZahid
ShahZahid 2020 年 12 月 16 日
回答済み: Ameer Hamza 2020 年 12 月 16 日
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));

回答 (1 件)

Ameer Hamza
Ameer Hamza 2020 年 12 月 16 日
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)

カテゴリ

Help Center および File ExchangeShifting and Sorting Matrices についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by