フィルターのクリア

Estimating two coefficients out of three in quadratic function

1 回表示 (過去 30 日間)
MariapL
MariapL 2017 年 11 月 19 日
コメント済み: Star Strider 2017 年 11 月 19 日
Hi Everybody, I need to estimate coefficients of this equation aN^2 + bN. It is standard quadratic function but coefficient c=0. My data is a time series, where:
x= [ 0, 5 ,9, 10,15, 16]
y= [715,901, 1139, 1224,1553,1712]
F=polyfit(x,y,3)
plot(F)
As you can see I am using polyfit, which gives me 3 coefficients: a=1.9029 b=30.1841 c=712.7646. I need c to be 0. Do you know any way to calculate only a and b, setting c as 0? I will much appreciate your help, as i am stuck a bit. Thank you :)

採用された回答

Star Strider
Star Strider 2017 年 11 月 19 日
Try this:
x= [ 0, 5 ,9, 10,15, 16];
y= [715,901, 1139, 1224,1553,1712];
F = [x(:).^2 x(:)]\y(:);
eqnstr = sprintf('F(x) = %.2f\\cdotx^2 + %.2f\\cdotx', F)
xv = linspace(min(x), max(x));
figure(1)
plot(x, y, 'pg')
hold on
plot(xv, polyval([F(:)' 0],xv), '-r')
hold off
grid
text(3, 1300, eqnstr)
  10 件のコメント
MariapL
MariapL 2017 年 11 月 19 日
It works too :) I deal with it by putting text(800,100,..) now its visible, becouse this point is actually on my plot. After I changed data the whole plot moved. :)
Star Strider
Star Strider 2017 年 11 月 19 日
As long as it works in your code, it’s correct!

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeProbability Distributions についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by