File Exchange

image thumbnail

degrees and radians

version 1.1 (1.55 KB) by

Two helper functions, one converts degrees to radians, the other rads to deg.

4.63636
11 Ratings

0 Downloads

Updated

View License

Editor's Note: This file was selected as MATLAB Central Pick of the Week

Two simple functions to save time writing out the code to do a degrees to radians calculation or vice versa.

Comments and Ratings (13)

Abel Luis

meu, você é o cara

Nathan Birch

Exactly what I was looking for, thank you.

Makes computation time longer. Very simple. Yet very useful at times.

Jeff Gibson

Good simple function. Any true programmer understands the importance of maintainability and code reuse from a software engineering perspective, espcially when the performance hit is infinitesimal.

Richard Medlock

Duane - yes you are probably correct, the original calculation however was done differently and was shorter. However, the benefit for me personally is two fold - 1) it makes it easier to troubleshoot the code because it's more readable and 2) repetitive calculations are generally best kept as functions which enable you to more easily find and replace them, and avoid mistakes in typing out duplicate code. But everyone has their own preferred way of doing things.

How does this save time? Function calling overhead makes this computationally slower than direct multiplication. Typing the function call degrees(theta) is 14 keystrokes whereas 180/pi*theta is only 12 keystrokes. The same is true for typing radians(theta). So how does this save time?

Joel

Joel (view profile)

Simple

Carson Smith

Thanks

Atul Kumar

padmanaban RPS

good yar

Seung-Bin Lim

ezekiel calderon

if only i knew earlier how to install the file, i would be a lot easier.

a a

thank you so much. you helped me out a whole lot.

Updates

1.1

Modified calculation based on a user suggestion to improve speed.

MATLAB Release
MATLAB 6.1 (R12.1)
Acknowledgements

Inspired: deg2rad and rad2deg conversion functions

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video