title: Difference between output of python librosa.core.stft() and matlab spectrogram(x)
body: <p>I am converting a Python code to MATLAB. The Python code, uses the following command:</p>
  
  <pre><code>stft_ch = librosa.core.stft(audio_input[:, ch_cnt], n_fft=self._nfft, 
                              hop_length=self._hop_len, win_length=self._win_len, 
                              window='hann')
  </code></pre>
  
  <p>Where <code>audio_input.shape=(2880000, 4)</code>, <code>self._nfft=2048</code>, <code>self._hop_len=960</code> and <code>self._win_len=1920</code>. </p>
  
  <p>When converting to MATLAB I used:</p>
  
  <pre><code>stft_ch = spectrogram(audio_input(:, ch_cnt), hann(win_len), win_len-hop_len, nfft);
  </code></pre>
  
  <p>where I verified <code>size(audio_input)=2880000, 4</code>, <code>win_len=1920</code>, <code>win_len-hop_len=960</code> and <code>nfft=2048</code>. </p>
  
  <p>I am getting an output from MATLAB with <code>size(stft_ch)=1025, 2999</code> where Python shows <code>stft_ch.shape=(1025, 3001)</code>.  The size <code>2999</code> in the MATLAB output is clear and feats the <a href="https://www.mathworks.com/help/signal/ref/spectrogram.html#bultmx7-s" rel="nofollow noreferrer">documentation</a> where <code>k = ⌊(Nx – noverlap)/(length(window) – noverlap)⌋</code> if window is a vector.</p>
  
  <p>However, I could not find in the <a href="https://librosa.github.io/librosa/generated/librosa.core.stft.html" rel="nofollow noreferrer">Python documentation</a> how is the length of <code>t</code> set. </p>
  
  <p>Why is there a difference between sizes? Is my conversion good? </p>
  
  <p>Is there a Python function which produces an output more similar to MATLAB's <code>spectrogram()</code> so that I can get the complex output with the same size?</p>