title: programming in matlab (how to process in real time)
body: <p>i am trying to make a spectrogram in matlab, 
  here is my code:</p>
  
  <pre><code>% Record your voice for 100 seconds.
  recObj = audiorecorder;
  disp('Start speaking.')
  recordblocking(recObj, 100);
  
  % Store data in double-precision array.
  my= getaudiodata(recObj);
  figure;
  specgram(my,512);
  </code></pre>
  
  <p>problem is that while i am speaking i want the spectrogram to be shown, so it should be updating as i speak. How can i plot the spectrogram while the audio is coming from microphone? so i should be able to see spectrogram in real time</p>
  
  <p>I also tried this </p>
  
  <pre><code>% Record your voice for 100 seconds.
  recObj = audiorecorder;
  disp('Start speaking.')
  a=0;
  figure;
  while a&lt;60
      recordblocking(recObj, 100);
  
      % Store data in double-precision array.
      my= getaudiodata(recObj);
  
      specgram(my,512);
      a=a+1;
  end
  </code></pre>
  
  <p>but it will only display the spectrogram when the while loop fishes (so after running 60 times)</p>