필터 지우기
필터 지우기

Sequential reading of an array using loop

조회 수: 3 (최근 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 CenterFile Exchange에서 Data Import and Export에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by