Plotting line of regression analysis

Hi, I'm trying to plot a line for my regression analysis on my scatter graph. I have calculated the regression using a function 'linear_regression' and it has given me the R2, slope and RMSE values as seen in the picture. How can I plot this line?
LR1=linear_regression (new_exp_wear_data,new_caliberated_pred_data );
figure(200);
scatter (new_exp_wear_data,new_caliberated_pred_data)
xlabel('experimental')
ylabel('predicted')

답변 (1개)

Scott MacKenzie
Scott MacKenzie 2021년 5월 13일

1 개 추천

Just add lsline after scatter ...
LR1=linear_regression (new_exp_wear_data,new_caliberated_pred_data );
figure(200);
scatter (new_exp_wear_data,new_caliberated_pred_data)
lsline; % add least squares regression line to scatter plot
xlabel('experimental')
ylabel('predicted')
Instead of lsline, you could use...
hold on;
plot(x, yFitted);

댓글 수: 1

Image Analyst
Image Analyst 2021년 5월 13일
Cool - I didn't know about that convenient function - lsline().

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Scatter Plots에 대해 자세히 알아보기

질문:

2021년 5월 11일

댓글:

2021년 5월 13일

Community Treasure Hunt

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

Start Hunting!

Translated by