Function or loop to get radians

4 views (last 30 days)
Tamia Eli
Tamia Eli on 19 Jul 2020
Edited: Bhupendra Prajapati on 19 Jul 2020
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

Answers (1)

Bhupendra Prajapati
Bhupendra Prajapati on 19 Jul 2020
Edited: Bhupendra Prajapati on 19 Jul 2020
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

Categories

Find more on Computational Geometry in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!