function result = sineWavVector(sampleRate,frequency,duration) %sineWavVector return a vector of sine wave samples %Consumes: sampleRate, a scalar number (samples per unit time) % frequency, a scalar number (cycles per unit time) % duration: length of the vector (in time units) % %Produces: a vector containing samples of a sine wave, % with the given frequency, at the given sample rate, % of the given duration. % % % Examples: % >> sineWavVector(4,1,2) % ans = % 0 1 0 -1 0 1 0 -1 0 % >> % Note that the length of the vector will be % (duration * sampleRate) + 1 % % >> sineWavVector(4,1,1) % ans = % 0 1 0 -1 0 % % Note: in following example, x stands for 1/sqrt(2) % % >> sineWavVector(8,1,1) % ans = % 0 x 1 x 0 -x -1 -x 0 % % >> sineWavVector(8,2,1) % ans = % 0 1 0 -1 0 1 0 -1 0 % interval = 1/sampleRate; k = 0:interval:duration; result = sin(2 * pi * k * frequency); return; end