i am trying to make a spectrogram in matlab,
here is my 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);
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
I also tried this
% Record your voice for 100 seconds.
recObj = audiorecorder;
disp('Start speaking.')
a=0;
figure;
while a<60
recordblocking(recObj, 100);
% Store data in double-precision array.
my= getaudiodata(recObj);
specgram(my,512);
a=a+1;
end
but it will only display the spectrogram when the while loop fishes (so after running 60 times)
Here is one possible implementation. The main problem was that you forget to call DRAWNOW at the end of each loop:
I simply display the frequency components in each iteration. You should be able to modify that to show the spectrogram if you want…