fitting a polynomial function to data points and ploting it

2 vues (au cours des 30 derniers jours)
som
som le 7 Nov 2011
Hi all
I want to fit a quadratic function to a data serie in MATLAB and calculate determination coefficient (R2) as well as quadratic equation.so desired outputs are as below: - scatter plot of data serie i.e. (x, y) - plot of quadratic fitting - quadratic equation - determination coefficient (R2) Could you please guide me. thanks

Réponse acceptée

Richard Willey
Richard Willey le 7 Nov 2011
If you have Curve Fitting Toolbox, you can generate everything you need as follows
X = 1:100;
X = X';
Y = X.^2 + 3*X + 5 + randn(100,1);
[foo Gof] = fit(X,Y, 'poly2')
scatter(X,Y)
hold on
plot(foo)

Plus de réponses (1)

Pawel Blaszczyk
Pawel Blaszczyk le 7 Nov 2011
doc polyfit
doc polyval
I think this two function will be enoguh :)

Catégories

En savoir plus sur Linear and Nonlinear Regression dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by