finding a coefficient from an equation

3 ビュー (過去 30 日間)
Ana Monea
Ana Monea 2020 年 5 月 18 日
コメント済み: Ana Monea 2020 年 5 月 18 日
Hello, i m a beginner on matlab and i would need some help. I have 2 vectors x and z with 10 values each and the equation z=c*sqrt(x). I have to find the value of c. Help please.
  3 件のコメント
Ana Monea
Ana Monea 2020 年 5 月 18 日
I forgot to mention that c is a constant. So i guess that i need to find just one value for c even if i have 10 values in each vector. I think i habe to use a command but i don t know which one.
Walter Roberson
Walter Roberson 2020 年 5 月 18 日
In that case either use / or \ operators with appropriate arguments. They will do a least-squared fitting to find the best value for c.

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

回答 (1 件)

Ang Feng
Ang Feng 2020 年 5 月 18 日
(1)If your vectors x and x follows exactly z=c*sqrt(x), then the constant c can be calculated, as mentioned by Adam Danz,
c = sqrt(x)./z
You have a vector c which has 10 identical value which is what you are looking for.
(2) In the case x, and z just follow then trend of z=c*sqrt(x), you are actually asking for a constant c that minimize some function of the error vector. Normally, we minimize norm of the square of the error . This is a least square problem. You can actually use the curve fitting tool box to fit the function.
sqrtX = sqrt(x);
f = fit(sqrtX,z,'poly1');
c = f.p1;
Here is my little example.
x = (1:10)';sqrtX = sqrt(x);
z = 2*sqrtX+0.05*randn(10,1);% add some noise
f = fit(sqrtX,z,'poly1');
c = f.p1
ans =
1.9725
The parameter c = 2 was calculated to be 1.9725.
  1 件のコメント
Ana Monea
Ana Monea 2020 年 5 月 18 日
Thanks for the help

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

カテゴリ

Help Center および File ExchangeComputational Geometry についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by