MATLAB: Hi, I need a function that calculates the sine of the corresponding element of an input. The input is in degrees and I am not allowed to use the built-in function sind.

cosinesinsindtaylor series

Hi, I need a function that calculates the sine of the corresponding element of deg. Deg are giving in degrees and I am not allowed to use sind. My code is as follows:
function [value,average]=sindeg(deg)
value=deg*pi/180;
average=sum(value)/numel(deg)
end
I know the result of value should be 0 1 0 for deg = [0 90 180].
Mine function is clearly wrong. Can you help. Thanks

Best Answer

Please think about it. A circle has 2*pi radians in its circumference (the units the sin function uses) and 360 degrees in its circumference. So:
2*pi radians = 360 degrees
I leave the rest for you.
As for writing the function, see the section on Anonymous Functions in the documentation on Function Basics (link).
EDIT Added ‘Function Basics’ link.