Function or loop to get radians

3 ビュー (過去 30 日間)
Tamia Eli
Tamia Eli 2020 年 7 月 19 日
編集済み: Bhupendra Prajapati 2020 年 7 月 19 日
Hello, I am a beginner. I want to find a function or a loop to transform degrees minutes and seconds of latitud and longtitude to radians, since I have some points to work with.
Inputs: Degrees, minutes, seconds, orientation (latitude), Degrees, minutes, seconds, orientation (longitude)
Outputs: Angle in radians of latitude, angle in radians of longitude.
I want the outputs to be saved in different variables, no, let it be overwritten, so I was thinking of calling a function. How would I do this? This is what I've done:
glat=input('\nLatDegrees: ');
mlat=input('\nMin: ');
slat=input('\nSec ');
gradlat=(glat+(mlat/60)+(slat/3600));
rlat=gradlat*(pi/180);%radianslat
v=0;
while(v==0)
senlat=input('\nHemishphere (N/S): ','s');
if(strcmp(senlat,'n')||strcmp(senlat,'N'))
siglat=1;
v=1;
else
if(strcmp(senlat,'s')||strcmp(senlat,'S'))
siglat=-1;
v=1;
else
fprintf('\nWrong');
v=0;
end
end
end
gradlat=siglat*gradlat;
rlat=gradlat*(pi/180);
glong=input('\nLonDeg: ');
mlong=input('\nMin: ');
slong=input('\nSec: ');
gradlong=(glong+(mlong/60)+(slong/3600));
v=0;
while (v==0)
senlong=input('\nHemisphere (E/W): ','s');
if(strcmp(senlong,'e')||strcmp(senlong,'E'))
siglong=1;
v=1;
else
if(strcmp(senlong,'w')||strcmp(senlong,'W'))
siglong=-1;
v=1;
else
fprintf('\nWrong');
v=0;
end
end
end
gradlong=(glong+(mlong/60)+(slong/3600));
rlong=gradlong*(pi/180);%radianslong

回答 (1 件)

Bhupendra Prajapati
Bhupendra Prajapati 2020 年 7 月 19 日
編集済み: Bhupendra Prajapati 2020 年 7 月 19 日
You can use
toRadians('degrees', gradlat)
to covert an angle in degrees to radian.
From more information visit the link given below ->
https://www.mathworks.com/help/map/ref/toradians.html

カテゴリ

Help Center および File ExchangeComputational Geometry についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by