Info

此问题已关闭。 请重新打开它进行编辑或回答。

How do I use the results of the polyfit command for the rest of my code?

1 次查看(过去 30 天)
Depending on a single variable 'x', I get a 2nd degree polynomial equation.I needed the values of the coefficients of this polynomial equation. I got those values using the 'polyfit' command. Now i need to use these values in the rest of the procedure. I think this procedure can be automated. How do i use the output of the 'polyfit' command, as input for the rest of the procedure?

回答(1 个)

Jos (10584)
Jos (10584) 2014-7-3
Useully you would like to use the parameters of the fit to obtained fitted values. Something along these lines, perhaps?
x = 1:10
y = 2 * x - 8
ynoise = y + randn(size(y)) % y-values with noise
p = polyfit(x,ynoise,1)
yfit = polyval(p,x) % fitted Y values
plot(x,y,'bo',x,ynoise,'rs', x,yfit,'r.-')
legend({'real','noisy','fitted'})
res = yfit - y % residuals

此问题已关闭。

Community Treasure Hunt

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

Start Hunting!

Translated by