필터 지우기
필터 지우기

Plotting best fit line

조회 수: 2 (최근 30일)
Ann
Ann 2021년 1월 4일
댓글: Ann 2021년 1월 4일
Hi everyone,
This is my coding and the figure below is the result. My data are all in excel file but now I don't know how to plot the fit slope.
Can anyone advice me? Thanks in advanced.
S4=xlsread('02-Feb-all.xlsx','N:N');
CStdev=xlsread('02-Feb-all.xlsx','P:P');
%_______________Read data_______________%
x=S4;
y=CStdev;
%______________________________%
figure%>>>>>>>>>>>>>>>>>>>>>>>>>>>>> FIGURE starts
scatter(x,y);
title('February 2014');
%datetick('x', 'HH');
xlabel('Ampilitude scintillation (S4)');
ylabel('Sigma-code-carrier Divergence (meters)');
hold all
%_______________PRNall_______________%

채택된 답변

KSSV
KSSV 2021년 1월 4일
Read about polyfit. If (x,y) are your data points.
p = polyfit(x,y,1) ;
yi = polyval(p,x) ;
scatter(x,y);
hold on
plot(x,yi,'r')
  댓글 수: 1
Ann
Ann 2021년 1월 4일
Oh My God! Thank you, man! It works!!!

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Data Import from MATLAB에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by