フィルターのクリア

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 Center および File ExchangeRegression についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by