function x = sinusoid(len,freq,mag,phase)
%
% function sinusoid(len,freq,mag,phase)
%
% returns an all real sinusoid with the following specifications.
%
% 	creates sinusoids of length	(len) 
%	with a frequency of		(freq) radians
%	with magnitudes of		(mag)
%	with phases			(phase) degrees
%
j = sqrt(-1);

t = [0:len-1]'/len;				% time
phase = phase*pi/180;

mr = sqrt( mag*mag/(1+tan(phase)^2) );
mi = -1*mr*tan(phase);

x = mr*cos(2*pi*freq*t) + mi*sin(2*pi*freq*t);
