# How to do linear fitting of data to get R square value and coeficient of a,b ?

3 visualizzazioni (ultimi 30 giorni)
Debarati Ghosh il 25 Nov 2023
Commentato: Debarati Ghosh il 27 Mar 2024
I got x and y value. I want to fit the date linearly . I want to get Rsquare value and value of a and b. How to do in matlab?
##### 0 CommentiMostra -2 commenti meno recentiNascondi -2 commenti meno recenti

Accedi per commentare.

### Risposte (1)

Ive J il 30 Nov 2023
n = 100;
x = randn(n, 1);
y = randn(n, 1);
mdl = fitlm(x, y)
mdl =
Linear regression model: y ~ 1 + x1 Estimated Coefficients: Estimate SE tStat pValue ________ _______ _______ _______ (Intercept) 0.014768 0.10405 0.14193 0.88742 x1 0.11976 0.10612 1.1286 0.26182 Number of observations: 100, Error degrees of freedom: 98 Root Mean Squared Error: 1.03 R-squared: 0.0128, Adjusted R-Squared: 0.00276 F-statistic vs. constant model: 1.27, p-value = 0.262
##### 1 CommentoMostra -1 commenti meno recentiNascondi -1 commenti meno recenti
Debarati Ghosh il 27 Mar 2024
@Ive J Thank you sir

Accedi per commentare.

### Categorie

Scopri di più su Get Started with Curve Fitting Toolbox in Help Center e File Exchange

### Community Treasure Hunt

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

Start Hunting!

Translated by