How to fit a polynom to known points without polyfit

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 Kommentar

David Goodmanson
David Goodmanson am 7 Mai 2020
Bearbeitet: David Goodmanson am 7 Mai 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).

Melden Sie sich an, um zu kommentieren.

 Akzeptierte Antwort

Walter Roberson
Walter Roberson am 7 Mai 2020

0 Stimmen

2 Kommentare

Thank you for this ressource. I'll try this right now.
This was very helpful. Got it now. Thanks a lot

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Produkte

Version

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by