I want to generate a high frequency (single) tone. I am using matlab (any other platform/tool for the same will also work). I am using the following snippet which I wrote by referring to various sources achieving similar specification.

```
amp = 10;
Fs = 44100;
duration = 60;
freq = 20000;
t = (0:1/Fs:duration-1/Fs);
%t = linspace(0,duration,Fs*duration);

wave = amp*sin(2*pi*freq*t);
%sound(wave, Fs);

audiowrite('20KHz-pilot.wav',wave,Fs);

draw_spec = 0;
if(draw_spec == 1)
    NFFT = 2048;
    wave = wave(1:NFFT);
    y = fft(wave);
    y = abs(y/NFFT);
    y = y(1:NFFT/2+1);

    % as 0 and Fs don't have any alias while others do
    % we need to double the power of the other frequencies since we are
    % converting from 2 sided power spectrum to single sided spectrum.
    y(2:end-1) = 2*y(2:end-1);

    f = Fs*(0:(NFFT/2))/NFFT;
    plot(f,y);
end

```

The problem I am facing is that when I load the file in audacity it shows frequencies other than 20KHz in fact 20Khz is not there in spectrogram. Further when I play the sound I can hear it which should not be the case (most adults have audio hearing range upto 18Khz). Also plotting spectrum of the wave in matlab only shows 20KHz.

I have tried to use common conventional variable names so the code should be pretty self explanatory.

I am not able to find where I am making a mistake, is there a mistake in the code or is it that due to sampling rate etc. there are other frequencies also generated (aliasing or similar concepts). I tried playing the sound on different speaker systems to check if it could be a hardware issue but that was not the case.

NOTE: I have browsed through multiple resources with similar question title as mine, unfortunately none of them were able to help me. Thus, I resorted to posting this question.