nonlinear fit with function a*exp((q1+i*q2)*x)/sqrt(x)
2 ビュー (過去 30 日間)
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.
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
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.