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일

1 개 추천

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일
Thank you. It worked.
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개)

태그

질문:

2017년 6월 24일

댓글:

2017년 6월 25일

Community Treasure Hunt

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

Start Hunting!

Translated by