title: Quantization noise in matlab
body: <p>I'm recording some voice in MATLAB and then quantizing it down from 16-bit to 1-bit so I can calculate the SNR but I'm not getting reasonable SNR figures. Anyone point me in the right direction?</p>
  
  <pre><code>% Store recorded audio signal in numeric array
  signal = getaudiodata(recording, 'int16');
  
  quanRate = 16;
  quantsignal = signal;
  
  while quanRate ~= 1
   quanRate = quanRate - 1;
  
   quantsignalHold = quantsignal;
  
   % Remove LSB using bitshift
   quantsignal = bitshift(quantsignal, -1);
  
   % Plot the quantized signal
   figure()
   plot(quantsignal);
   title(['Sample recording at ' num2str(quanRate) '-bits']);
   xlabel('Sample number') % x-axis label
   ylabel('Sample value') % y-axis label
  
   % Calculate the quantisation error 
   quantError = quantsignal - signal; 
  
   % Calculate the SNR
   SNR = snr(signal,quantError); 
  
   disp(['The SNR of the ' num2str(quanRate) '-bit recording is: ' num2str(SNR) ' dB'])
  end
  </code></pre>