필터 지우기
필터 지우기

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 CenterFile Exchange에서 Probability Distributions에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by