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

AttachmentLast UpdateSize
d2r.mOct. 28, 2014, 10:31 p.m.190 bytes


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