frequency equation for curve fitting

60 views (last 30 days)
Hello All,
Is there any equation frequency based for exponential decaying cosine signals to fit on measure data for optimization or curve fitting method?
Thank you

Accepted Answer

Star Strider
Star Strider on 9 Sep 2019
To do a nonlinear fit in the frequency domain, you will need to calculate a function that is the Fourier transform of the time-domain function you want to fit.
Try this:
syms k1 k2 t Tmax w w0
y(t,w0,k1,k2) = exp(k1*t) * cos(k2*w0*t)
Y = int(y*exp(1j*w*t), t, 0, Tmax)
Y = simplify(Y, 'Steps',250)
Yf = matlabFunction(Y) % Individual Parameters
Yf = matlabFunction(Y, 'Vars',{[w0,k,Tmax],w}) % Parameter Vector ‘in1’
producing:
Yf = @(in1,w) -(in1(:,2)+w.*1i)./((in1(:,2)+w.*1i).^2+in1(:,1).^2)+(exp(in1(:,3).*in1(:,2)+in1(:,3).*w.*1i).*(in1(:,1).*sin(in1(:,3).*in1(:,1))+cos(in1(:,3).*in1(:,1)).*(in1(:,2)+w.*1i)))./((in1(:,2)+w.*1i).^2+in1(:,1).^2);
where ‘k’ (‘in(:,2)’) is the exponential decay constant, ‘w0’ (‘in(:,1)’) is the frequency of the cosine function, and ‘Tmax’ (‘in(:,3)’)is the maximum (end) time of the vector, and ‘w’ is the independent variable and radian frequency. Note that this produces a complex result, so it might be easiest to take the abs() of it and use it with the abs() of the Fourier transform. Also, as written here, ‘in’ is defined as a row vector, and will throw an error if you use a column vector as your initial parmeter estimates.
I have never done any nonlinear parameter estimation in the frequency domain, so I have no experience with it. I also did not test this function with the Fourier transform of a decaying cosine function, so I have no idea if it will succeed.
Have fun!
  53 Comments
Ill ch
Ill ch on 16 Mar 2021
Hello Star Strider,
Almost, after one year again on matlab query :). I wish you are fine and very well in this COVID 19 time.
I have uploaded one more question on my current isssues. I hope you can help me there.
as i had forgotten this id so created new and uploaded there.
Thank you very much in advance
Best regards,
Ic

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!