How to solve polyfit(x,y,1) by hand?

9 ビュー (過去 30 日間)
Husain Alshati
Husain Alshati 2018 年 4 月 24 日
コメント済み: Husain Alshati 2018 年 4 月 25 日
Hello so I know how to find polyfit using matlab but how do I find it without matlab? I need to know how to do it for linear equations like polyfit(x,y,1) can we assume that x=[1 2] and y=[3 4] and thanks alot I appreciate the help

回答 (2 件)

John D'Errico
John D'Errico 2018 年 4 月 25 日
To solve it without MATLAB, just read ANY of hundreds of books or websites about linear regression modeling.
Start here:
https://en.wikipedia.org/wiki/Linear_regression
  3 件のコメント
Guillaume
Guillaume 2018 年 4 月 25 日

I tried that but couldn't find anything

You're kidding, right? There are zillions of books dedicated to linear regressions. The wikipedia article that John linked also explains it all.

In addition you can even look at the code of polyfit and see for yourself exactly how it does it.

Husain Alshati
Husain Alshati 2018 年 4 月 25 日
Then maybe you could find something from these zillions of books because I could not.

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


Torsten
Torsten 2018 年 4 月 25 日
If you only have two points for a polynomial of degree 1, you have to solve a linear system of two equations:
3 = a*1 + b
4 = a*2 + b
for a and b.
The equation of the line is then given by
y = a*x + b
Best wishes
Torsten.

カテゴリ

Help Center および File ExchangeFunction Creation についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by