how to calculate optimal value of a unknown constant of an equation with known data points?

6 ビュー (過去 30 日間)
Hey, I wanted to solve for the optimal value of constant. I have data points of the equation .
please help, how can I do that.
equation is:
y= 1/sqrt(k^2+x^2)

採用された回答

Walter Roberson
Walter Roberson 2020 年 9 月 11 日
k0 = rand() * 10;
bestk = lsqcurvefit( @(k,x)1./sqrt(k.^2+x.^2), k0, x, y);
  7 件のコメント
Adam Danz
Adam Danz 2020 年 9 月 11 日
We don't know what to do either without knowing the full error message :)
If you're looking for an optimal k, Walter's approach is probably the one you want to pursue. If you have questions about your results, we need the inputs you're using so we can reproduce the results.
pooja sudha
pooja sudha 2020 年 9 月 11 日
Hey Thanks Adam and Walter , I found the result :)

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

その他の回答 (1 件)

Adam Danz
Adam Danz 2020 年 9 月 10 日
k = sqrt((1/y)^2 - x^2)
  3 件のコメント
Adam Danz
Adam Danz 2020 年 9 月 11 日
% assign demo values
k = 2.2; % = 2.2
x = 1:10; % = [1,2,3,4,5,6,7,8,9,10]
y = 1./sqrt(k^2 + x.^2); % = [0.41 0.33 0.26 0.21 0.18 0.15 0.13 0.12 0.10 0.09]
% Solve for k
k = sqrt((1./y).^2 - x.^2) % = [2.2 2.2 2.2 2.2 2.2 2.2 2.2 2.2 2.2 2.2 ]
k = sqrt((1/y(1))^2 - x(1)^2) % = 2.2
Or, as Walter shows, you can use mean(), mode(), median().

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

カテゴリ

Help Center および File ExchangeQuadratic Programming and Cone Programming についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by