MATLAB: How can I generate a random angle

random angle

I want to plot a random straight line with a fixed length based on the coordinates of a random point. Therefore I need to find a random angle. I figured everything out but the angle.

Best Answer

Try one of these:
rangrad = 2*pi*rand; % Radians
rangdeg = 360*rand; % Degrees
Experiment to get the result you want.