Function or loop to get radians
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
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
0 comentarios
Respuestas (1)
Bhupendra Prajapati
el 19 de Jul. de 2020
Editada: Bhupendra Prajapati
el 19 de Jul. de 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
0 comentarios
Ver también
Categorías
Más información sobre Loops and Conditional Statements en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!