MATLAB Answers

nonlinear fit with function a*exp((q1+​i*q2)*x)/s​qrt(x)

조회 수: 2(최근 30일)
Jiong Yang
Jiong Yang 2021년 5월 7일
댓글: Jiong Yang 2021년 5월 10일
I am trying to do a nonlinear fit of the attached data, which is the blue decaying sine or cosine wave in the attached image.
I want to fit the data into the function of a*exp((q1+i*q2)*x)/sqrt(x), where a, q1 and q2 are real numbers.
I have tried to use lsqnonlin, but could not limit those three fitting variables to be real. And the fitted results do not make sense.
Any help will be much appreciated.
  댓글 수: 5
Jiong Yang
Jiong Yang 2021년 5월 10일
Thank you, Alex. Problem solved already.

댓글을 달려면 로그인하십시오.

채택된 답변

Bjorn Gustavsson
Bjorn Gustavsson 2021년 5월 7일
This seems like you need to take a standard step from the physicsist's complex representation (which admittedly we often use a bit carelessly as a very convenient(!) shorthand). My guess is that you need to do something like this:
% your model-function: the real part of a modified damped oscillating
% exponential:
curve_fcn = @(pars,x) real((pars(1)+1i*pars(2))*exp((pars(3)+1i*pars(4))*x)./sqrt(x));
err_fcn = @(pars,x,y,fcn) sum((y-fcn(pars,x)).^2);
par0 = [-0.1378e-8, -0.0541e-8, 4.1643e+03, 2.3100e7]; % this might have to be adjusted to get a good enough start-guess
parBest = fminsearch(@(pars) err_fcn(pars,x,y,curve_fcn),par0);
You might have to iterate the optimization-step with the parameter estimate parBest as the new input for par0 to get a improved fits.
You might consider a properly weighted sum-of-square optimization instead of the straight-forward sum-of-squares, but in order to do that you'll need estimates of the uncertainties (standard-deviation) of each measurement point.
  댓글 수: 3
Jiong Yang
Jiong Yang 2021년 5월 10일
It really helps. Thank you very much!
Now I have a almost perfect fit for the first 4 peaks. I am not too worried about the double peak at the end, as the data is the inverse fourier transform of the fourier transform of the original data.

댓글을 달려면 로그인하십시오.

추가 답변(0개)

Community Treasure Hunt

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

Start Hunting!

Translated by