Alternates of polyval and polyfit?

조회 수: 4 (최근 30일)
Manny
Manny 2021년 3월 9일
답변: Walter Roberson 2021년 3월 9일
I'm working on an assignment that has to do with interpolating polynomials where I create a picture reading in the data points from a file. However, I am not allowed to use the functions polyfit or polyval. How would I go about finding the coefficients of a polynomial and generating a curve based on those coefficients?

채택된 답변

Walter Roberson
Walter Roberson 2021년 3월 9일
Suppose you had a polynomial of degree 2, y = a2*x^2 + a1*x^1 + a0*x^0, a2, a1, a0 unknown then you can write that as
[x^2, x^1, x^0] * [a2; a1; a0] = y
Now fill in those values as columns for all known x, y
A = [x1^2, x1, 1
x2^2, x2, 1
x3^2, x3, 1
...]
b = [y1;
y2
y3
...]
and then it follows that
A * [a2; a1; a0] = b
which is a (possibly overdetermined) system of simultaneous linear equations you can solve by your favorite method

추가 답변 (0개)

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by