Hello,
I have the data points
x = [22.96, 88.2, 114.275, 85.3] y = [0.1422, 0.157967, 0.202167, 0.1612]
and I want to fit the equations
y =(L/Vr)-((L/4.316)*cosd(x))
to determine the value of L and Vr.
L should be in the range from 0.0 - 1.7
Vr should be in the range from 2.0 - 6.0
Can anyone help?
Thank you

 採用された回答

Star Strider
Star Strider 2018 年 3 月 14 日

1 投票

Try this:
fy = @(L,Vr,x) (L./Vr)-((L./4.316).*cosd(x));
x = [22.96, 88.2, 114.275, 85.3];
y = [0.1422, 0.157967, 0.202167, 0.1612];
B = fmincon(@(b) norm(y - fy(b(1),b(2),x)), [1; 4], [],[],[],[],[0 2],[1.7 6.0])
fprintf('L = %.15f\nVr = %.15f\n', B)
xv = linspace(min(x), max(x));
figure(1)
plot(x, y, 'pg')
hold on
plot(xv, fy(B(1),B(2),xv), '-r')
hold off
grid
L = 0.347528298961989
Vr = 2.000000558931784

2 件のコメント

Joel Lowe
Joel Lowe 2018 年 3 月 26 日
Hello again,
Thank you for your answer. Is there a way of outputting the residual misfit?
Thanks
Star Strider
Star Strider 2018 年 3 月 26 日
My pleasure.
Calculate the residuals as:
resid = y - fy(B(1),B(2),x);
The objective function calculates the norm of the residuals, so if you want those as well, ask fmincon for fval:
[B, resnorm] = fmincon(@(b) norm(y - fy(b(1),b(2),x)), [1; 4], [],[],[],[],[0 2],[1.7 6.0])
so ‘resnorm’ has the norm of the residuals.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Community Treasure Hunt

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

Start Hunting!

Translated by