[英]Matlab - how to use specgram function?
唉...我不給陰謀例如,作為Matlab的specgram
和spectrogram
,但我會給另一種方式來做到這一點。
首先,您要使用FFT將時域信號轉換為短時頻域(STFT):
這可以通過matlab specgram
完成:
[data,fs,bit] = wavread('test.wav'); %//Read in WAV file
%//Note if you have dual channel or multi-channel, you need to do each channel separately, or add them to create mono-channel. In my example, which is voice, I use a single channel recording.
teststft = spectrogram(data); %//This is rough, and usually results in terrible results;
%//I suggest you set your input parameters suitable for voice/music/etc - Note I used hamming window of 256 length, 50% overlap and 512 nfft - which creates roughly 30ms time frames, suitable for voice.
teststft = spectrogram(data(:,1),hamming(256),50,512);
%//In your plotting example, you have used something like the Log Magnitude response, which can be expressed as:
testSTFT = log(abs(teststft));
%//and finally, to plot:
figure
surf(STFT, 'edgecolor', 'none'); view(0,90); axis tight;
xlabel('Time');
ylabel('FrequencyDistribution');
grid on;
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.