Reputation: 458
I'm trying to write a function that calculates Radian (Decimals) to Degrees.
For example
radiansToDegrees(1.5) = 1° 30' 00"
This is my logic:
fix()
, take the whole number before the decimal. This will be the degree.0.5
in the above case) and multiply by 60
. From the answer, take the whole number before the comma. This becomes the minutes.0
in the above case) and multiply by 60
. This becomes the seconds.I'm only able to reach step one. How do I retain only the fraction part of a number, especially if its something like this 0.8987724
Upvotes: 2
Views: 851
Reputation: 3159
You may use functions from the Mapping Toolbox:
degrees = rad2deg(1.5)
dms = degrees2dms(degrees)
--------------------------------
dms = [85.0000, 56.0000, 37.2094]
Upvotes: 1