频谱图及其含义

4

我非常想知道如何生成http://en.wikipedia.org/wiki/Spectrogram中右上角的图片(脚本)以及如何分析它,即它传达了什么信息?我希望得到一个简化的答案,尽量避免使用数学术语。谢谢。


2
也许 DSP.stackexchange 更合适... - Andrey Rubshtein
我正在寻找一个编程解决方案,但我无法理解太多数学术语在数字信号处理中的技术负载!这就是为什么我在这里提问。谢谢。 - Sm1
4
目前形式的问题不适合在dsp.se上发布,请不要在那里重新提问。至于文章中右上角的图表,您可以访问其页面以获取更多详细信息。作者使用Adobe Audition创建了它,所使用的音频文件也可用。您可以使用MATLAB的spectrogram文档中的基本示例来自己完成,并在编程方面遇到困难时在[so]上寻求帮助。 - user616736
2个回答

3

该图显示时间沿水平轴,频率沿垂直轴。像素颜色显示每个时刻的每个频率的强度。

通过将信号分成小的时间段,并对每个段进行傅里叶级数,可以生成频谱图。

下面是一些用于生成频谱图的Matlab代码。

请注意,直接绘制信号时,它看起来像垃圾,但是绘制频谱图后,我们可以清楚地看到组成信号的频率。

%%%%%%%%
%% setup
%%%%%%%%

%signal length in seconds
signalLength = 60+10*randn();

%100Hz sampling rate
sampleRate = 100;
dt = 1/sampleRate;

%total number of samples, and all time tags
Nsamples = round(sampleRate*signalLength);
time = linspace(0,signalLength,Nsamples);

%%%%%%%%%%%%%%%%%%%%%
%create a test signal
%%%%%%%%%%%%%%%%%%%%%

%function for converting from time to frequency in this test signal
F1 = @(T)0+40*T/signalLength; #frequency increasing with time
M1 = @(T)1-T/signalLength;    #amplitude decreasing with time

F2 = @(T)20+10*sin(2*pi()*T/signalLength); #oscilating frequenct over time
M2 = @(T)1/2;                              #constant low amplitude

%Signal frequency as a function of time
signal1Frequency = F1(time);
signal1Mag = M1(time);

signal2Frequency = F2(time);
signal2Mag = M2(time);

%integrate frequency to get angle
signal1Angle = 2*pi()*dt*cumsum(signal1Frequency);
signal2Angle = 2*pi()*dt*cumsum(signal2Frequency);

%sin of the angle to get the signal value
signal = signal1Mag.*sin(signal1Angle+randn()) + signal2Mag.*sin(signal2Angle+randn());

figure();
plot(time,signal)


%%%%%%%%%%%%%%%%%%%%%%%
%processing starts here
%%%%%%%%%%%%%%%%%%%%%%%

frequencyResolution = 1
%time resolution, binWidth, is inversly proportional to frequency resolution
binWidth = 1/frequencyResolution;

%number of resulting samples per bin
binSize = sampleRate*binWidth;

%number of bins
Nbins = ceil(Nsamples/binSize);

%pad the data with zeros so that it fills Nbins
signal(Nbins*binSize+1)=0;
signal(end) = [];

%reshape the data to binSize by Nbins
signal = reshape(signal,[binSize,Nbins]);

%calculate the fourier transform
fourierResult = fft(signal);

%convert the cos+j*sin, encoded in the complex numbers into magnitude.^2
mags= fourierResult.*conj(fourierResult);

binTimes = linspace(0,signalLength,Nbins);
frequencies = (0:frequencyResolution:binSize*frequencyResolution);
frequencies = frequencies(1:end-1);

%the upper frequencies are just aliasing, you can ignore them in this example.
slice = frequencies<max(frequencies)/2;

%plot the spectrogram
figure();
pcolor(binTimes,frequencies(slice),mags(slice,:));
< p > fourierResult 矩阵的傅里叶逆变换将返回原始信号。


0

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接