How to fit a polynom to known points without polyfit

11 views (last 30 days)
Hello there,
I'm new to matlab and I was given the task to fit a polynom to a set of known points without using polyfit by my teacher. I've been dabbling around for hours now and I just can not figure it out.
Here are the given Points:
(-3|0) (-2|0) (-1|0) (0|0) (2|0) (2.5|0)
And I was given the Point (1|1)
I figured out how to fit the polynom to the y=0 points but I can not figure out how to fit it to the (1|1)
Here is my code so far (without the plot)
x = linspace(-4,3,701)' ; % x-Achse
NSx = [ -3 -2 -1 0 2 2.5 ]'; % Bekannte Werte x
%
% y1 = 0;
%
ko = 0;
p = poly(NSx);
y1 = polyval(p,x);
Can somebody please help me solve this issue?
  1 Comment
David Goodmanson
David Goodmanson on 7 May 2020
Edited: David Goodmanson on 7 May 2020
Hi Valentn,
If p(x) is a polynomial with a certain set of roots, then p(x)*(x-a) is a polynomial one degree higher that still has the same roots as p(x), correct? (plus one more). You can use this fact to help get a fit to (1,1).

Sign in to comment.

Accepted Answer

Walter Roberson
Walter Roberson on 7 May 2020

More Answers (0)

Categories

Find more on Polynomials in Help Center and File Exchange

Products


Release

R2018b

Community Treasure Hunt

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

Start Hunting!