% 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

 채택된 답변

Brendan Hamm
Brendan Hamm 2015년 3월 2일
편집: Brendan Hamm 2015년 3월 2일

0 개 추천

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);

추가 답변 (1개)

카테고리

도움말 센터File Exchange에서 Linear and Nonlinear Regression에 대해 자세히 알아보기

질문:

2015년 3월 2일

답변:

2015년 3월 2일

Community Treasure Hunt

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

Start Hunting!

Translated by