MATLAB Answers

finding a changing dominant tone in a signal

2 views (last 30 days)
wouter koomen
wouter koomen on 24 Feb 2016
Commented: wouter koomen on 26 Feb 2016
For my Thesis I am analysing aircraft noise, in here a fan tone is visible when creating a spectrogram, however after removing background noise by removing a large moving average form the original. When searching for peaks in a small time bin, 100ms, the remaining found peaks are still quite noisy.
A different approach was for every 100ms, get the corresponding samplepoints, use a bandpass filter so only the intersing part is left, where the fan tone is expected and fititng that to a sin and using the non lineair optimization toolbox in matlab to find the optimum. However, if I want to do this automatically, so using code, the fit is not as good as my starting points dont change. When doing it manually these points get chosen by matlab, and those are optimized starting points. Is there any way to change the mode in my code to make matlab determine optimal values? Instead of the hard coded number array I am using at the moment?


Sign in to comment.

Answers (1)

Kevin Claytor
Kevin Claytor on 24 Feb 2016
Have you tried:
Raw data -> BP filter -> Spectrogram -> peak finding
You seem to have the parts for it, and I would expect it to be faster than nonlinear fitting.
But if you're dead-set on fitting instead, most of the fitting routines have the option for initial parameters. For example, when using fit from the CF toolbox, you can use fitOptions to specify your initial parameters, which can be drawn from the data programatically;
frequency = fan_freq;
f_low = 0.8*frequency;
f_high = 1.2*frequency;
amplitude = max(data) - min(data);
a_low = 0.8*amplitude;
a_high = 1.2*amplitude;
phase = ...
fo = fitoptions('Startpoint', [frequency, amplitude, phase],...
'Lower', [f_low, a_low, p_low],...
'Upper', [f_high, a_high, p_high]);
ft = fittype('a*sin(f*x +p)', 'independent', {'x'}, 'coefficients', {'f', 'a', 'p'}, 'options', fo)
fit(x, data, ft)
Just make sure to match the order of 'coefficients' to the order in 'startpoints', 'lower', and 'upper'.


wouter koomen
wouter koomen on 26 Feb 2016
Thanks for your reply! the main problem is setting my initial parameters, for example the value it should be is 6660 which corresponds to f=1060, this however only works if my starting value is 6600 or 6700, otherwise the fititng will give a different value. My first approach was indeed as you mentioned:
Raw data -> BP filter -> Spectrogram -> peak finding
However I thought maybe this new method might yield better results, sometimes the data is quite noisy and it is quite hard to distinguish the harmonic with my eyes let alone the algorithm.
however when I use the tool the starting value is set at 6630, which is chosen by the program. Is there a way to set the starting value option to automatic in my code?
wouter koomen
wouter koomen on 26 Feb 2016
alright it seems commenting or removing the startpoint from the code solves my problem and the alternative way works as well.

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!