Reputation: 15
I want to have 7_order polynomial fit for my histogram, but I don’t want to plot it, I need the polynomial function with its coefficients to get new data. How can I get this?
Upvotes: 0
Views: 225
Reputation: 1073
If you want to get new data from a polynomial function (that fits your original data points), you must first find the coefficients using polyfit
.
In the example below, you calculate the 7th-degree polynomial that variable p
holds and you generate new data, using polyval
, so y1
holds these data.
x = linspace(0,4*pi,10);
y = sin(x);
p = polyfit(x,y,7);
x1 = linspace(0,4*pi);
y1 = polyval(p,x1);
Upvotes: 1