4.42857

4.4 | 7 ratings Rate this file 243 downloads (last 30 days) File Size: 1.55 KB File ID: #3263

degrees and radians

by Richard Medlock

 

13 Apr 2003 (Updated 18 Aug 2009)

Code covered by BSD License  

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

Editor's Notes:

This file was selected as MATLAB Central Pick of the Week

Download Now | Watch this File

File Information
Description

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

MATLAB release MATLAB 6.1 (R12.1)
Zip File Content  
Other Files degrees.m,
license.txt,
radians.m
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (9)
05 Apr 2004 a a

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

29 Nov 2004 ezekiel calderon

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

18 Nov 2006 Seung-Bin Lim  
29 Aug 2007 padmanaban RPS

good yar

11 Jan 2008 Atul Kumar  
15 Mar 2008 Carson Smith

Thanks

13 Aug 2009 Joel

Simple

21 Aug 2009 Duane Hanselman

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?

19 Nov 2009 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.

Please login to add a comment or rating.
Updates
18 Aug 2009

Modified calculation based on a user suggestion to improve speed.

Tag Activity for this File
Tag Applied By Date/Time
radians Richard Medlock 22 Oct 2008 06:59:46
degrees Richard Medlock 22 Oct 2008 06:59:46
deg2rad Richard Medlock 22 Oct 2008 06:59:46
rad2deg Richard Medlock 22 Oct 2008 06:59:46
angles Richard Medlock 22 Oct 2008 06:59:46
convert Richard Medlock 22 Oct 2008 06:59:46
deg2rad Mark Pawlewski 23 Oct 2009 06:58:30
potw Shari Freedman 25 Nov 2009 11:41:57
 

MATLAB Central Terms of Use

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Terms prior to use.

Contact us at files@mathworks.com