% demonstration of beat note formed by adding two sinusoids whose frequencies
% are closely spaced
%
% r kakarala
% UCBx DSP I

fs=8192;  %sampling rate
f1=999;   % two closely 
f2=1004;  % spaced frequencies

t=0:1/fs:3;   % three seconds at sampling rate of 8192 Ha.
x1=cos(2*pi*f1*t);
x2=cos(2*pi*f2*t);

pause;
% play x1
soundsc(x1);
pause;
% play beat note
soundsc(x1+x2,fs);

% plot beat note
plot(t,x1+x2);
title('beat note');
xlabel('t (seconds)');