clear;

Fs=44100;       % Sampling rate (Hz)
f0=440;         % Tone pitch (Hz)
AdB=-18;        % Amplitude (dB)
Afull=1;        % Full range amplitude is 1
Duration=1;     % Tone duration (s)

N=Duration*Fs;          % Computes total samples
Ts=1/Fs;                % Computes Samling Period (s)

Alin = 10^(AdB/20);     % Convert Amplitude from dB to linear

for (n=0:N-1)
    s(n+1)=Alin*sin(2*pi*f0*n*Ts);  % n is the time index (t=n*Ts)
end

plot(s(1:fix(10*(Fs/f0))));     % show it graphically
%plot(s);
s = audioplayer(s,Fs);                  % play it
play(s);