Polynomial curve fitting--how to use cubic
1 view (last 30 days)
Show older comments
I have this code:x=[1.69,1.99,1.99,1.99,1.99,1.99,2.70,2.70,2.70,3.00,3.00,3.00,3.00,3.37,3.37]; plot(x,'r-'); I use the tool "Figure"-"Tools\Basic Fitting"-"cubic" to do the Polynomial curve fitting,but I don't know how to write down the code about "cubic",it's grateful if somebody can help me.
0 Comments
Accepted Answer
Matt Fig
on 18 Mar 2011
Do you mean, how to get the coefficients from the command line?
PP = polyfit(1:length(x),x,3);
EDIT
To plot the polynomial, use:
hold on
xp = linspace(1,length(x),100);
yp = polyval(PP,xp);
plot(xp,yp,'b-')
5 Comments
Jan
on 18 Mar 2011
I'm not a native speaker, but I have the strong impression that there is a difference between "guys" and "gays".
If Matt Fig's answer solves your problem, please accept it.
More Answers (0)
See Also
Categories
Find more on Linear and Nonlinear Regression 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!