Can I improve my result using Linear Model.stepwise but how can I use 'polyijk' with my example?

1 view (last 30 days)
x1=[];
y1=[];
for k=1:4:412
x1=A(:,k+2);
y1=A(:,k);
xx=find(y1);
xxx=max(xx);
y2=smooth(x1(1:xxx),y1(1:xxx),'moving',3);
[p S mu]= polyfit(x1(1:xxx),y2,3);
f=polyval(p,x1(1:xxx));
for l=1:xxx
A(l,k)=A(l,k)-f(l);
end
Can I use Linear Model.stepwise but want to know how can I use with this?
Type of error coming how can I make good results warning(message('MATLAB:polyfit:RepeatedPoints'));
In polyfit at 74 Warning: Polynomial is badly conditioned. Add points with distinct X values or reduce the degree of the polynomial.
I am using this
[p S mu]= polyfit(x1(1:xxx),y2,3);

Answers (1)

dpb
dpb on 28 Aug 2013
warning(message('MATLAB:polyfit:RepeatedPoints'));
In polyfit at 74 Warning: Polynomial is badly conditioned. Add points with distinct X values or reduce the degree of the polynomial.
how can I make good results
Follow the directions. You've got too many repeated (or nearly so) independent variable values. Since the polynomial degree chosen was 3, try quadratic instead (polynomials of higher degree are seldom a good choice, anyway, altho there are always exception).
But since a cubic isn't terribly high power, one presumes you don't have many points to begin with and they're not well placed across the range of x.

Categories

Find more on Polynomials in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!