Fitting an Exponential Downchirp signal

4 visualizaciones (últimos 30 días)
Michael Lherbette
Michael Lherbette el 2 de Feb. de 2016
Hello,
My aim is to fit a chirp to extract frequency, amplitude, and phase. Here is the chirp a generate
It is an exponential downchirp signal starting at 25 Hz then end at 0.2 Hz with amplitude 5e-3.
Of course the data that I will get from my experiments will be i) noisy, ii) amplitude will change according to the frequency, iii) so do the phase. But I want to work on easy signal first then move into hard stuff.
My ideas are, to fit the curve: - find each local minima and maxima to get 1 period of the signal. - then fit the period to a y(t) = Amplitude*sin(2*pi*Frequency*t+Phase) - Then move to the other period of the curve and do the fitting again.
Here are the results I am getting
The amplitude of the signal seems ok, but get some issues with the frequency and the phase (why those low values) Here is one part of the code I wrote:
defl = load('DwellDriveWave.txt'); %The file with the downchirp signal generated
defl =defl';
time = linspace(0,3.5,length(defl)); %definition of the time vector
time = time;
[pks,locs] = findpeaks(defl); %find local maxima
DeflInv = -1.*defl; %inverse deflection to find minima
[pksinv,locsinv] = findpeaks(DeflInv); %find local minima
Then I define the position (vector postime) of the starting and ending of the period. Piece of code too big thus not put here. Then I do the fitting according to each period:
% Definition of the fit function
fitfun=@(A,x) A(1)*sin(2*pi*A(2).*x+A(3)); %A(1) the amplitude, A(2) the frequency, A(3) the phase.
EndFrequency = 25; %Here we define the bet values
StartFrequency = 0.2; %by creating a vector with the
TrueEnd = 3.5; %exponential downchirp expected
CoefficientK = (EndFrequency/StartFrequency)^(-1/TrueEnd); %
fguess = EndFrequency*CoefficientK.^(linspace(0,time(postime(end)),length(postime)));%
A0 = [max(defl),fguess(i),-pi]; %Initial parameters
f = zeros(3,length(postime)-1);
chi = zeros(1,length(postime)-1);
opts = statset('nlinfit');
opts.RobustWgtFun = 'welsch';
for i = 1:length(postime)-1
[f(:,i),R,J,CovB,MSE] = nlinfit(time(postime(i):postime(i+1)),...
defl(postime(i):postime(i+1)), fitfun,A0,opts);
chi(i) = 1-sum(R.^2)/sum((defl(postime(i):postime(i+1))- ...
mean(defl(postime(i):postime(i+1)))).^2);
A0(2) = fguess(i+1);
end
So I would like to know if you have any hints why the frequency I am getting is not the initial one, and why the phase I have is so low. I bet there is a problem with the definition of the time vector in the fitting but ....
Cheers !

Respuestas (0)

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by