How to plot more multiple different regression lines in matlab

5 ビュー (過去 30 日間)
amj
amj 2017 年 12 月 16 日
コメント済み: amj 2017 年 12 月 17 日
Hi, I going to plot multiple regression lines in a Figure with different regression coefficient of each line. The purple data points are the predicted values based on different regression lines. I m not going to use the polyfit() or polyval() because i have my own way to generate the regression coefficient. Based on the the equation below:
for i=1:length(pointsMissing)
if (K==2)
X(pointsMissing(i),2) = b2(1) + b2(2) * X(pointsMissing(i),1) + err_z2(i);
else
X(pointsMissing(i),2) = b1(1) + b1(2) * X(pointsMissing(i),1) + err_z1(i);
end
end
I really hope that anyone can give me some ideas on how to do that. Thank you

採用された回答

Jos (10584)
Jos (10584) 2017 年 12 月 16 日
If you have the regression coefficients (a,b) (a sin the formula: y = ax +b), the command
h = refline(a,b)
will plot this line in the current graph. Using the handle h, you can set all aspects, like colour
h.Color = 'r' ;
  2 件のコメント
amj
amj 2017 年 12 月 16 日
Thanks a million Jos (10584). Let me try
amj
amj 2017 年 12 月 17 日
Dear Jos (10584), It is works as what i want.. Thank you very much

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLinear Regression についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by