Is it possible to extract also R^2 value from linear fit between 2 vectors ?
Show older comments
Hello,
I know that it is possible to find fit parameters using polyfit command.
F.e., linearCoefficients = polyfit(x, y, 1)
Is it possible to extract also R^2 value from linear fit between 2 vectors ?
Thank you !
Accepted Answer
More Answers (1)
Lola Davidson
on 25 Nov 2025
As of R2024a, polyfit will actually do this for you.
x = 1:10;
y = randn(size(x)) + 0.2*x;
[linearCoefficients,structOutput] = polyfit(x, y, 1);
Rsq = structOutput.rsquared;
Categories
Find more on Descriptive Statistics and Insights 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!