create a linear regression that finds r and r^2 in matlab using a function in matlab
main.m
% Example datax = [1:5];
y = [23546];
% Getting the coefficients for the linear regressioncoefficients = polyfit(x, y, 1);
m = coefficients(1);
b = coefficients(2);
% Calculating the predicted valuesy_pred = m*x + b;
% Calculating R and R^2r = corrcoef(x, y);
R = r(1,2);
R_squared = R^2;
disp(['R value is: ', num2str(R)]);
disp(['R^2 value is: ', num2str(R_squared)]);