%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% GENERATE A SINE WAVE AT 440 Hz for 5 seconds
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

f=440;                               % frequency of the signal
fs = 44100;                          % sampling frequency (in Hz)
nsec = 5;                            % number of seconds
n = 1:fs*nsec;                       % samples
y = sin(2*pi*n*f/fs);                % generate the signal
sound(y, fs)                         % play this on the speakers
audiowrite('note_440Hz.wav', y, fs); % save it to a WAV file

