Plotting line of regression analysis

7 ビュー (過去 30 日間)
Mahshad Rabiee
Mahshad Rabiee 2021 年 5 月 11 日
コメント済み: Image Analyst 2021 年 5 月 13 日
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 日
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().

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeScatter Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by