How do I use the results of the polyfit command for the rest of my code?
Info
Diese Frage ist geschlossen. Öffnen Sie sie erneut, um sie zu bearbeiten oder zu beantworten.
Ältere Kommentare anzeigen
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?
Antworten (1)
Jos (10584)
am 3 Jul. 2014
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
Diese Frage ist geschlossen.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!