Find peaks from spectrogram

9 views (last 30 days)
Hans Binderup
Hans Binderup on 8 Feb 2018
Answered: Star Strider on 8 Feb 2018
Hey there.
I'm working with FSK generation and decoding. I currently have generated a signal containing 3 characters. These characters have been assigned different frequencies with my generator script.
I have made a spectrogram analysis of the signal:
Now I want to identify the different frequencies. I have tried everything from max, findpeaks etc. But when I convert my signal with the spectrogram function, I end up with entirely different frequencies and peaks. I have also made DFT analysis of my signal, but I end up with weird results. BTW. I have made a script that divided the signal into 3 parts (in this case of 1 second). Now I just need to find the dominant frequency during this time period.
Generator code:
function x = FSKgenerator(mysymbolseq, fstart, fend, Tsymbol, fs)
% fstart = 1000; % transmission band frequency start
% fend = 2000; % transmission band frequency end
% Tsymbol = 0.5; % symbol duration in seconds
% fs = 20000; % sampling frequency
farray = linspace(fstart, fend, 256); % 256 frequencies spread out in band
A = 1; % amplitude
n = 0:(round(Tsymbol*fs)-1);
myids = double(mysymbolseq); % convert 'abcd' to [97 98 99 100].. ie. 256 possible values
x = []; %empty array
for i=1:length(myids),
myfreq = farray(myids(i)); % choose freq for current char
sig = A*cos(2*pi*n*myfreq/fs); % create signal
x = [x sig]; % add to full signal
end
Code for generating this signal:
clc, clear, close all
fstart = 1000; % transmission band frequency start
fend = 2000; % transmission band frequency end
Tsymbol = 1; % symbol duration in seconds
fs = 10000; % sampling frequency
signal = FSKgenerator('Hej', fstart, fend, Tsymbol, fs);
figure(1)
spectrogram(signal, hanning(1000), 0, 500, fs)

Answers (1)

Star Strider
Star Strider on 8 Feb 2018
This is similar to locating DTMF tones. See for example How can i detect frequency of dtmf tone (.wav) file (link).
If you already know the tones you want to detect, see if the goertzel (link) function will do what you want.

Categories

Find more on Time-Frequency Analysis in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!