フィルターのクリア

how to prolong best fit line to reach to x-axis ?

4 ビュー (過去 30 日間)
Amr Hashem
Amr Hashem 2015 年 10 月 19 日
コメント済み: Star Strider 2015 年 10 月 20 日
I draw a best fit line
but I want to prolong it to x-axis, how to do this ?
I use this code:
figure;
h=bar(val,n,'b');
axis([-5 25 0 95]);
grid on
hold on
A=[1;17];
B=[16;92];
plot(A, B, 'go')%, 'LineWidth', 1, 'MarkerSize', 10);
coeffs = polyfit(A, B, 1);
fittedX = linspace(min(A), max(A), 200);
fittedY = polyval(coeffs, fittedX);
plot(fittedX, fittedY, 'r-', 'LineWidth', 3);
how to prolong the best fit line ?

採用された回答

Star Strider
Star Strider 2015 年 10 月 19 日
Change the linspace call to:
fittedX = linspace(-coeffs(2)/coeffs(1), max(A), 200);
  2 件のコメント
Amr Hashem
Amr Hashem 2015 年 10 月 20 日
Thanks
Star Strider
Star Strider 2015 年 10 月 20 日
My pleasure!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeGraphics Object Programming についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by