簡體   English   中英

Matlab-如何使用頻譜圖函數?

[英]Matlab - how to use specgram function?

我通過[data,fs,bit] = wavread('*。wav');加載了wav文件; 我想使用specgram函數可視化此wav文件。

像這樣!

在此處輸入圖片說明

讓我知道如何像這樣顯示可視化的wav文件。 (我想分析wav文件聲音的頻率)

唉...我不給陰謀例如,作為Matlab的specgramspectrogram ,但我會給另一種方式來做到這一點。

首先,您要使用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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM