필터 지우기
필터 지우기

how to fit a trend line in plotyy ?

조회 수: 2 (최근 30일)
SONI SONI
SONI SONI 2015년 3월 2일
답변: Image Analyst 2015년 3월 2일
% 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일
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개)

Image Analyst
Image Analyst 2015년 3월 2일
See my attached polyfit demo.

카테고리

Help CenterFile Exchange에서 Regression에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by