谱图及其含义 [英] Spectrogram and what it is

查看:114
本文介绍了谱图及其含义的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我很想知道如何生成右上图:http://en.wikipedia.org/wiki/Spectrogram
生成(脚本)以及如何分析它,即它传达了什么信息?我希望用最小的数学术语来简化答案。谢谢。

I am very interested to know how the top right figure in :http://en.wikipedia.org/wiki/Spectrogram is generated (the script) and how to analyse it i.e what information does it convey?I would appreciate a simplified answer with minimum mathematical jargons. Thank you.

推荐答案

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

The plot shows time along the horizontal axis, and frequency along the vertical axis. With pixel color showing the intensity of each frequency at each time.

通过采集信号并将其切割成小时段来生成频谱图,在每个频段上执行傅里叶级数细分。

A spectrogram is generated by taking a signal and chopping it into small time segments, doing a Fourier series on each segment.

这里有一些生成一个的matlab代码。

here is some matlab code to generate one.

注意如何直接绘制信号,它看起来如何比如垃圾,但是绘制频谱图,我们可以清楚地看到分量信号的频率。

Notice how plotting the signal directly, it looks like garbage, but plotting the spectrogram, we can clearly see the frequencies of the component signals.

%%%%%%%%
%% 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,:));

fourierResult 矩阵的逆傅里叶变换,将返回原始信号。

The inverse Fourier transform of the fourierResult matrix, will return the original signal.

这篇关于谱图及其含义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆