How to convert radians to degrees?
17 次查看(过去 30 天)
显示 更早的评论
Hi, I have this code,
clear all, close all, clc,
r = 0.08;
t = 2;
for n = 1:180,
M(1,n) = r*cos(t); %x length from center
M(2,n) = r*sin(t); %y length from center
t = t+2;
end
It is meant to find the x,y distance from the center of a circle with fixed radius (Basically calculating x,y coordinates of circumference).
However the coordinates are coming wrong and it is because Matlab is performing calculations in radians rather than in degrees. (I cross checked the values with calculator) And I don't know how to convert to radians, and none of the forum results made sense to me.
Thanks, Rohan
0 个评论
回答(3 个)
José-Luis
2013-5-21
编辑:José-Luis
2013-5-21
There is a built in function for that:
doc deg2rad
But it is rather trivial to implement it yourself:
myTrans = @(x) x./360.*(2.*pi());
myTrans(180)
ans =
3.1416
6 个评论
Ivan-V-Timofeev
2014-11-4
deg2rad
It does not work without toolbox > geo > private > deg2rad.m http://mooring.ucsd.edu/software/matlab/doc/toolbox/geo/private/deg2rad.html
另请参阅
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!