Can't plot polyfit
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Ander Azpitarte
el 19 de Oct. de 2020
Comentada: Adam Danz
el 19 de Oct. de 2020
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?
0 comentarios
Respuesta aceptada
Star Strider
el 19 de Oct. de 2020
Editada: Star Strider
el 19 de Oct. de 2020
p = polyfit(x,y,n)
where ‘n’ is the degree (1=linear, 2=quadratic, etc.).
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 comentario
Más respuestas (0)
Ver también
Categorías
Más información sobre Linear and Nonlinear Regression en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!