필터 지우기
필터 지우기

Can't plot polyfit

조회 수: 4 (최근 30일)
Ander Azpitarte
Ander Azpitarte 2020년 10월 19일
댓글: Adam Danz 2020년 10월 19일
REGRE_FG=polyfit(FGS(86:99),FGS(86:99))
figure
plot(REGRE_FG)
I have this code where
[FGEl(86:99),FGS(86:99)]
ans =
0.0011 80.3471
0.0011 81.5330
0.0012 82.7614
0.0012 83.9897
0.0012 85.1755
0.0012 86.3615
0.0014 92.1641
0.0015 97.8820
0.0016 103.5999
0.0018 109.3179
0.0019 115.0781
0.0021 120.7112
0.0022 126.3021
0.0024 131.8082
However, MATLAB says:
Not enough input arguments.
Error in polyfit (line 56)
V(:,n+1) = ones(length(x),1,class(x));
Does anyone know how to solve this? Also, does anyone know how to write the polyfit equation?

채택된 답변

Star Strider
Star Strider 2020년 10월 19일
편집: Star Strider 2020년 10월 19일
The polyfit function also needs to know what degree of polynomial you want to fit:
p = polyfit(x,y,n)
where ‘n’ is the degree (1=linear, 2=quadratic, etc.).
Also, in order to plot it, you will need to evaluate it first with the polyval function.
EDIT — (19 Oct 2020 at 198:10)
Since your data are linearly related, the full code would go something like this —
REGRE_FG=polyfit(FGEl(86:99),FGS(86:99),1);
REGRE_FG_fit = polyval(REGRE_FG,FGEl(86:99));
figure
plot(FGEl(86:99),FGS(86:99), 'p')
hold on
plot(FGEl(86:99), REGRE_FG_fit, 'r')
hold off
grid
xlabel('FGEl')
ylabel('FGS')
.
  댓글 수: 1
Adam Danz
Adam Danz 2020년 10월 19일
refline() is another way of plotting the regression line, too (example), although it doesn't have an option to plot the error estimates like polyval does.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Fit Postprocessing에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by