Constraining Polyfit with known coefficients

Hi. I am performing a 5th order polynomial fit to some data X,Y and use the following syntax
p5=polyfit(x,y,5)
f5=polyval(p5,x);
This performs the best fit and gives me coefficient of all the x's.
How can I restrain this as I know for sure that x^2 & x^4 = 0 (so their coefficients can be set to zero) and the coefficient infront of X is 26. I then want to perform the fit, but only allow the routine to adjust X^5, & X^3 coefficients.
Thanks Jason

1 Kommentar

Jason
Jason am 15 Mai 2015
Bearbeitet: Jason am 15 Mai 2015
I've done it (I think)
ft=fittype('a*x^5+b*x^3+26*x');
fitobj,~,~,~]=fit(x,y,ft) %[fitobj, goodness, output, convmsg]=fit(x,y,ft)
coeff1=fitobj.a;
coeff2=fitobj.b;
yfit=coeff1*x.^5+coeff2*x.^3+26*x; %Remember dot notation
r=y-yfit; %Calc residuals

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Kategorien

Mehr zu Get Started with Curve Fitting Toolbox finden Sie in Hilfe-Center und File Exchange

Gefragt:

am 14 Mai 2015

Bearbeitet:

am 15 Mai 2015

Community Treasure Hunt

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

Start Hunting!

Translated by