MATLAB Answers

Fitting data to an equation with complex part

3 ビュー (過去 30 日間)
Baris Gungordu
Baris Gungordu 2020 年 4 月 9 日
コメント済み: Alex Sha 2020 年 4 月 17 日
I hope you are all well.
I have experimental data for a diaphragm displacement and want to fit it to the following equation. The experimental data is displacement (H in meters) and frequency (w in rad/s).
I have a working code but it is changes a lot with the initial guess. I need help to improve this.
x(1) is the alpha (numerator) and x(2) is the damping. omega_r is the resonant frequency and it is known. Gamma should be between 0.04 and 0.07. I am interested in gamma, the damping term in the denominator.
% non linear fitting
fun = @(x,omega)(x(1)./(omega_r^2 - omega.^2 + 1i*(2*x(2)*omega_r.*omega)));
x0 = [-35.9811 + 1i*23.8154,0.06];
opts = optimoptions(@lsqcurvefit,'Display','off','Algorithm','trust-region-reflective');
[vestimated,resnorm] = lsqcurvefit(fun,x0,omega,H,[],[],opts);
Looking forward to your suggestions.
Best regards,
Edit: x0 is changed.

  13 件のコメント

表示 10 件の古いコメント
J. Alex Lee
J. Alex Lee 2020 年 4 月 10 日
I am no longer clear on the problem or objective. Baris, what do you mean gamma is a "positive complex number"? If both alpha and gamma are complex, are there any constraints that you need to ensure that H_model remains real? Or as Alex has asserted, are you chopping off the imaginary part of the H_model? Actually, even if gamma is strictly real, the second part of the question remains.
Is the issue that your solution is too sensitive to initial guess?
Baris Gungordu
Baris Gungordu 2020 年 4 月 10 日
Hi J. Alex,
Both values (gamma & alpha) can be complex. Damping is usually a complex number with real positive part. Due to the structure of the equation this implies that alpha can be complex or real.
Right now, the my code with lsqcurve fit works but it produces the results same as x0 with 'trust-region-reflective' algorithm. With 'levenberg-marquardt' its very sensitive to X0.
Baris Gungordu
Baris Gungordu 2020 年 4 月 10 日
Hi Alex Sha,
Can we have that code transferred in MATLAB by any chance? What would you think about the use of lsqcurvefit or another algorithm to match that results in MATLAB?



Alex Sha
Alex Sha 2020 年 4 月 11 日
lsqcurvefit is seneitive to initial start-values since it use local optimization algorithm, same as cftool, there is a GA toolbox with global optimization algorithm in Matlab, unfortunately, the effects of GA are not so good as expected.

  2 件のコメント

Baris Gungordu
Baris Gungordu 2020 年 4 月 12 日
Well maybe MATLAB support team knows how to deal with this.
J. Alex Lee
J. Alex Lee 2020 年 4 月 13 日
I don't know that it's helpful to try to characterize the methods''s really sensitivity, i.e., the nature of the optimization problem that is important. If your optimization landscape is bumpy, as Alex Sha says, methods like Levenberg and trust-region may only find local bumps, depending on how much control you have over the size of the search space. On the other hand, if you have a very smooth optimization landscape, you might be fine. On the other hand, if your optimization landscape is smooth but flat, most algorithms will have trouble because no set of parameters will look any better than the next.
This is why I recommended characterizing your specific problem to the extent possible by studying norm(res) (and its gradient) as a function of your fit parameters.
It looks like you have a 4 parameter fit (2 real parts and 2 complex parts). But depending on how the model works (since you only care about real part of H), it's possible that you're over-specifying, in which case your sensitivity might have to do with multiple combinations of your 4 parameters result in the same real part of the model.


その他の回答 (1 件)

Baris Gungordu
Baris Gungordu 2020 年 4 月 17 日
Hi Alex Sha,
Would you mind studying the same equation with the attached data? Your 0.03 with 1stOpt was very accurate and I want to double check a model I found with a different data.
Best regards,

  1 件のコメント

Alex Sha
Alex Sha 2020 年 4 月 17 日
Hi, if all are as previous except the data, then the result will be:
Root of Mean Square Error (RMSE): 0.478025304038979
Sum of Squared Residual: 133.220275528809
Correlation Coef. (R): 0.994221627528188
R-Square: 0.9884766446448
Parameter Best Estimate
-------------------- -------------
x1.realpart 828282884.340485
x1.imagpart -136314338.186314
x2.realpart 0.681537210289169
x2.imagpart 9.3260946979766



Community Treasure Hunt

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

Start Hunting!

Translated by