Azzera filtri
Azzera filtri

Plotting best fit line

2 visualizzazioni (ultimi 30 giorni)
Ann
Ann il 4 Gen 2021
Commentato: Ann il 4 Gen 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_______________%

Risposta accettata

KSSV
KSSV il 4 Gen 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 Commento
Ann
Ann il 4 Gen 2021
Oh My God! Thank you, man! It works!!!

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Data Import from MATLAB in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by