image thumbnail

Spectrogram, STFT, with varied kinds of Plots

by

 

Plots STFT using line, Stem, Surface, Image. STFT calculation done using in built function

spectrogram_multiplot_demo.m
%% Creating dummy data

Fs = 500;       %Sampling frequency
T = 1/Fs;       %Sample time
L = 400;      %Length of signal
t = (0:L-1)*T;

s1 = 5*sin(2*pi*50*t) + 5*sin(2*pi*120*t);
s2 = 5*sin(2*pi*200*t);

signal = [s1 s2];
tp = (0:2*L-1)*T;
plot(tp,signal);
title('Original Signal');

%signal contains a mix of 50 and 120 Hz in the begining then 200Hz sinusoid
%So in the spectrogram you must see peaks at 50 and 120 for first half then
%a peak at 200Hz.

%Calling each type of plot

%% Line

spectrogram_multiplot('Line',signal,128,120,[50 120 200],500);
%Notice that I am providing the list of interested frequencies instead of
%nfft parameter.

%% Stem

spectrogram_multiplot('Stem',signal,128,120,[50 120 200],500);
%Notice that I am providing the list of interested frequencies instead of
%nfft parameter.


%% Surface

spectrogram_multiplot('Surface',signal,128,120,256,500);

%% Image

spectrogram_multiplot('Image',signal,128,120,256,500);

Contact us