how to fit a trend line in plotyy ?
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
SONI SONI
le 2 Mar 2015
Réponse apportée : Image Analyst
le 2 Mar 2015
% code
y = [1:120]';
plotyy(y,data1,y,data2);
hold on
% plot(y,intercept + slope*y);
according to this code how can fit a trend line in data2
0 commentaires
Réponse acceptée
Brendan Hamm
le 2 Mar 2015
Modifié(e) : Brendan Hamm
le 2 Mar 2015
You could use:
p = polyfit(y,data1,n); % looks like you want n=1 in your case
p contains the coefficients of the line:
fitLine = p(1)*y + p(2);
or equivalently:
fitLine = polyfit(p,y);
0 commentaires
Plus de réponses (1)
Voir également
Catégories
En savoir plus sur Linear and Nonlinear Regression 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!