How to show regression line over my plot?

2 ビュー (過去 30 日間)
Pritha Pande
Pritha Pande 2017 年 6 月 24 日
コメント済み: KSSV 2017 年 6 月 25 日
I have made scatter plot using the command below.
aa=scatter(MERRA_combined(:),MISR_combined(:))
xlim([0 1])
ylim([0 1])
xlabel('MERRA 2')
ylabel('MISR')
title('Aerosol Optical Depth')
I wish to add regression line to this plot. I have attached the variables.

採用された回答

KSSV
KSSV 2017 年 6 月 24 日
編集済み: KSSV 2017 年 6 月 24 日
doc lsline
Or..use the below code:
load x_axis.mat ;
load y-axis.mat ;
aa=scatter(MERRA_combined(:),MISR_combined(:)) ;
xlim([0 1])
ylim([0 1])
xlabel('MERRA 2')
ylabel('MISR')
title('Aerosol Optical Depth')
%%fit line
x = MERRA_combined(:) ;
y = MISR_combined(:) ;
% remove NaN's from y
x(isnan(y)) = [] ;
y(isnan(y)) = [] ;
P = polyfit(x,y,1);
%
x0 = min(x) ; x1 = max(x) ;
xi = linspace(x0,x1) ;
yi = P(1)*xi+P(2);
hold on
plot(xi,yi,'r') ;
  3 件のコメント
Pritha Pande
Pritha Pande 2017 年 6 月 24 日
編集済み: Pritha Pande 2017 年 6 月 24 日
One more thing,how to add 1:1 line in the same plot?
KSSV
KSSV 2017 年 6 月 25 日
What do you mean by 1:1 line?

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

その他の回答 (0 件)

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by