MATLAB Answers

# frequency equation for curve fitting

17 views (last 30 days)
Ill ch on 9 Sep 2019
Commented: Ill ch on 19 Dec 2019
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

#### 0 Comments

Sign in to comment.

### Accepted Answer

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 on 19 Dec 2019
There is no any problem. Just i am confuse with Amplitude A =84 which comes from curve fitting optimized result from the following equation.
syms A delta phi t Tmax w w0
y(t,w0,A,delta,phi) = A*exp(-delta*t) * cos(w0*t-phi)
Y = int(y*exp(1j*w*t), t, 0, Tmax)
Yf = matlabFunction(Y, 'Vars',{[w0,A,delta,phi,Tmax],w}) % Parameter Vector ‘in1’
I am confuse with amplitude unit. Why on y axis amplitude is very small. Or the amplitude which stets on y-axis is not the amplitude which i am getting from the equation from above?
from your sentense:
The amplitude units are the same for frequency and time domain signals, unless they are deliberately changed. (For example, to use the Fourier transform for power spectral density, the amplitude is squared, so the units are power, not voltage. That is not done here, so I am using this only as an illustration.)
That means in my case Amplitude unit is Voltage? A=84 seems very high voltage in equation.
Thank you again
Star Strider on 19 Dec 2019
I have long since lost track of what we were doing.
I have no idea why the amplitude should be 84 when it otherwise appears to be as small as it is in other analyses, such as the Fourier transform.
Ill ch on 19 Dec 2019
Ohh No. i wish that you can think on it. I will be more thankful to you Sir.
I have generally presentation after two week so i am preparing for it.
Thank you very much in advance

Sign in to comment.