필터 지우기
필터 지우기

How to implement without function.?

조회 수: 1 (최근 30일)
Lalit Patil
Lalit Patil 2013년 1월 21일
polyfit(x,y,1)
How to implement the same thing without function..?

답변 (2개)

Walter Roberson
Walter Roberson 2013년 1월 21일

Jan
Jan 2013년 1월 21일
I assume that this is a homework question. There are good reasons to look for a faster implementation than Matlab's polyfit, but you do not ask for speed.
At first you need to construct the Vandermonde matrix. There are a lot of different algorithms to get it, and Google or WikiPedia know more details.
At second the least squares problem must be solved. V \ y with the Vandermonde matrix V and the y values is sufficient. A QR decomposition is more stable, so I suggest to try it and ask again in case or problems.
Be sure to use properly scaled inputs for x: A mean of 0 and a standard deviation of 1 is a fair choice to support the numerical stability of the algorithm. It is easy to consider the scaling afterwards.

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by