function y = myCosine(theta,units)
%Input: an angle theta and optional second argument 'units'
%Output: cos(theta) in degrees if units = 'deg' and radians otherwise
    if (nargin == 2) && strcmp(units,'deg')
        y = cos(DegToRadians(theta));
    else
        y = cos(theta);
    end
end


function r = DegToRadians(d)
% Converts degrees to radians. 
    r = d*pi/180;
end