how to get whole integers only using degrees2dms

1 view (last 30 days)
Im writing a function that returns a bearing given any azimuth. I have everything working except i want degrees2dms to only output whole numbers. Decimals are currently useless to me in this function so i would prefer to have whole numbers.
when i input 75.50275 as an angle into the function it returns [75, 30, 9.90] when I want it to return [75, 30, 10]. I want it to round down if the decimal is less than 5 and round up if it is equal or greater than 5. ie: 9.1 rounds to 9 while 9.6 rounds to 10
any help would be appreciated.

Answers (1)

Shadaab Siddiqie
Shadaab Siddiqie on 16 Nov 2020
From my understanding you want to round result from degrees2dms function. To solve this you can use round() function on the result.
result = round(degrees2dms(75.50275));
For more information you can refer round.

Products


Release

R2019b

Community Treasure Hunt

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

Start Hunting!