how to fit a trend line in plotyy ?

% 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

 Respuesta aceptada

Brendan Hamm
Brendan Hamm el 2 de Mzo. de 2015
Editada: Brendan Hamm el 2 de Mzo. de 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);

Categorías

Más información sobre Linear and Nonlinear Regression en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 2 de Mzo. de 2015

Respondida:

el 2 de Mzo. de 2015

Community Treasure Hunt

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

Start Hunting!

Translated by