% generateSinusoid - generate a sinusoidal signal using vectorized code

%% Set Parameters
A   = 3;     % amplitude
f   = 440;   % frequency
phi = -pi/4; % phase

fs = 20e3;   % sampling rate
Ts = 0;      % start time
Te = 10e-3;  % end time

%% generate sinusoid
%initialize loop variables
tcur = Ts;
kk   = 1;

while( tcur <= Te)
    % compute current sample and store in vector
    tt(kk) = tcur;
    xx(kk) = A*cos(2*pi*f*tcur + phi);
    
    %increment loop variables
    kk   = kk+1;
    tcur = tcur + 1/fs;
end