Spectrogram and what is it

I am very interested to know what the upper right figure looks like in: http://en.wikipedia.org/wiki/Spectrogram (script) and how to analyze it, and what information does it transmit? I would appreciate a simplified answer with minimal mathematical jargon. Thanks.

+3
image-processing matlab
source share
2 answers

The graph shows time along the horizontal axis and frequency along the vertical axis. With a color of pixels showing the intensity of each frequency at any given time.

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

here is some kind of matlab code to generate.

Pay attention to how the signal is directly printed, it looks like garbage, but, having built a 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,:)); 

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

+3
source share

To add to Saki's answer, here is a great tutorial that walks you step by step by reading Matlab spectrograms, touching only enough mathematics and physics to explain the basic concepts intuitively:

http://www.caam.rice.edu/~yad1/data/EEG_Rice/Literature/Spectrograms.pdf

0
source share

All Articles