Computing

MATLAB - Degrees to Radians

Last updated: Aug. 5, 2007, 7:03 p.m.

This is one of the earliest bits of MATLAB code that I wrote. It's basically a one line function that converts an input value in degrees to radians. The code is so simple I have no doubt that all users of MATLAB would be able to write it with a few moments of thought, however, I often found it useful to have this function in my path when writing code to allow me to call it without having to think, e.g. sin(d2r(alpha)) where alpha was the angle in degrees.

Source Code

function r = d2r(d)
%d2r version 0.1.0
%A simple conversion function
%Degrees to Radians
%Syntax: {angle in radians}=d2r({angle in degrees})
%Author: Nathan Dumont, October 2005

r=d/180*pi;
AttachmentLast UpdateSize
d2r.mApril 23, 2014, 9:06 p.m.190 bytes
Section:
Computing
Tags:
 

Comments

Posting comments is not currently possible. If you want to discuss this article you can reach me on twitter or via email.


Contact

Email: nathan@nathandumont.com

Twitter: @hairymnstr

Links