How to get best fitting Parameters for a function for all datapoints

syms lh lo r
U_in = 10;
w = 2*pi*[111452 131857 142436 157777 195689 230000 260000 347213 400000];
u_ll = [9.015 9.25 9.37 9.53 9.765 10 10 10 10];
b1_ll = w(1) * (lh +lo);
b2_ll = w(2) * (lh +lo);
b3_ll = w(3) * (lh +lo);
eqn1 = (u_ll(1) == abs((r+1i*b1_ll)*U_in/(50+r+1i*b1_ll)));
eqn2 = (u_ll(2) == abs((r+1i*b2_ll)*U_in/(50+r+1i*b2_ll)));
eqn3 = (u_ll(3) == abs((r+1i*b3_ll)*U_in/(50+r+1i*b3_ll)));
eqns = [eqn1, eqn2, eqn3];
[s_lh, s_lo, s_r] = solve(eqns,[lh lo r]);
Warning: Unable to find explicit solution. For options, see help.

답변 (1개)

Torsten
Torsten 2023년 10월 5일
이동: Torsten 2023년 10월 5일
You cannot estimate lh and lo separately in your approximating model, only their sum (lh+lo).
But your model seems to return constant values - independent of your fitting parameters.
U_in = 3;
w = 2*pi*[111452 131857 142436 157777 195689 230000 260000 347213 400000];
u_ll = [9.015 9.25 9.37 9.53 9.765 10 10 10 10];
fun = @(x) u_ll-abs((x(1)+1i*w*x(2))*U_in./(50+x(1)+1i*w*x(2)));
sol = lsqnonlin(fun,[2 -5])
Initial point is a local minimum. Optimization completed because the size of the gradient at the initial point is less than the value of the optimality tolerance.
sol = 1×2
2 -5
r = sol(1)
r = 2
lho = sol(2)
lho = -5

카테고리

도움말 센터File Exchange에서 Get Started with Curve Fitting Toolbox에 대해 자세히 알아보기

태그

질문:

2023년 10월 5일

이동:

2023년 10월 5일

Community Treasure Hunt

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

Start Hunting!

Translated by