title: Plotting FFT Amplitude Spectrum signal in Matlab
body: <p>I've trouble with plotting a correct FFT Amplitude Spectrum signal in decibels and Hertz.</p>
  
  <p>Firstly, I just plot the FFT Spectrum signal in Hz and magnitude like this:</p>
  
  <pre><code>figure;
  X_mags = abs(fft(signal));
  bin_vals = [0 : N-1];
  freq_ax_bins = bin_vals*fs/N;
  N_2 = ceil(N/2);
  plot(freq_ax_bins(1:N_2), X_mags(1:N_2));
  title('FFT Spectrum signal 1');
  xlabel('Frequency (Hz)')
  ylabel('Magnitude');
  </code></pre>
  
  <p>This results in the expected plot with magnitude always > 0. Finally, I just want to do the same but in decibels:</p>
  
  <pre><code>bin_vals = [0 : N-1];
  freq_ax_Hz = bin_vals*fs/N;
  N_2 = ceil(N/2);
  figure;
  plot(freq_ax_Hz(1:N_2), 10*log10(X_mags(1:N_2)));
  xlabel('Frequency (Hz)')
  ylabel('Amplitude (dB)');
  </code></pre>
  
  <p>It looks good but the plot is partially drawn into minus dB. Can someone show me how to correctly draw the spectrum in decibels?</p>