Effacer les filtres
Effacer les filtres

Plotting best fit line

2 vues (au cours des 30 derniers jours)
Ann
Ann le 4 Jan 2021
Commenté : Ann le 4 Jan 2021
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_______________%

Réponse acceptée

KSSV
KSSV le 4 Jan 2021
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 commentaire
Ann
Ann le 4 Jan 2021
Oh My God! Thank you, man! It works!!!

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Data Import from MATLAB dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by