title: Octave specgram generates two diffent answers
body: <p>I have a project where I have to recognize the frequency from an audio file. For this I use a single tone of 10 kHz to see if I can get it working. 
  Since I am pretty new to Octave, I tried <a href="http://octave.sourceforge.net/signal/function/specgram.html" rel="nofollow noreferrer">this example</a> with my own audio file.
  I tried to understand what happens by doing some research to all functions.</p>
  
  <p>My question here is; if I let specgram plot the figure when I do not specify it's output:</p>
  
  <pre><code>specgram(y,fftn,Fs,hanning(window),step);
  </code></pre>
  
  <p>it gives a line at 10kHz which is what I want.</p>
  
  <p>But if I specify the output for the specgram function </p>
  
  <pre><code>[S,f,t]= specgram(y,fftn,Fs,hanning(window),step);
  </code></pre>
  
  <p>and let it plot, it plots the line at 18 kHz. </p>
  
  <p>I figured it have to be in the inputs for the figure and I tried modifying these a bit, but every time I do that Octave gives an error. 
  I need the frequency as an given output, since I have to do some calculations with it, I figured I need to specify the frequency output. </p>
  
  <p>This is the part of the code that specify the plot for the spectrogram:</p>
  
  <pre><code>step= fix(5*Fs/1000);           % stepsize of the window
  window= fix(90*Fs/1000);        % window size 
  fftn =2^nextpow2(window);       % Size of the FFT block
  
  [S,f,t]= specgram(y,fftn,Fs,hanning(window),step); 
  
  S= abs(S(2:fftn*12000/Fs,:));   % Normalize the phase
  S= S/max(S(:));                 % Normalize the Energy
  S= max(S, 10^(-40/10));         % Throw out values below -40 dB and above -3dB
  S= min(S, 10^(-3/10));      
  figure
  imagesc(t,f,(log(S)));
  </code></pre>
  
  <p>Can anyone help me here how to gain the frequency data from the audio file so I can use it in some calculations?</p>
  
  <p>I have searched for answers already in the Octave manual for help and I tried it with various matlab sites. Also checked already many posts here such as:</p>
  
  <p><a href="https://stackoverflow.com/questions/12197769/how-does-octave-spectrogram-specgram-from-signal-work">How does Octave spectrogram &#39;specgram&#39; from signal work?</a></p>
  
  <p><a href="https://stackoverflow.com/questions/23418313/methodology-of-fft-for-matlab-spectrogram-short-time-fourier-transform-functio">Methodology of FFT for Matlab spectrogram / short time Fourier transform functions</a></p>
  
  <p>P.S. Sorry for my bad English, it's not my native language</p>