Community Tip - You can subscribe to a forum, label or individual post and receive email notifications when someone posts a new topic or reply. Learn more! X

Translate the entire conversation x

How to Polynomial Fit on Mathcad Prime 10

AkmarulSalleh
5-Regular Member

How to Polynomial Fit on Mathcad Prime 10

Hello Mathcadeers,

I am trying to polynomial curve fitting, but could not find any good example on how to do it.

let say I have the following. How do I create a function y1(x1)? Seems Mathcad function "polyfit" function is not the right one.Thanks. 

AkmarulSalleh_0-1737040429564.png

 

Regards,

Ak

 

ACCEPTED SOLUTION

Accepted Solutions

3 REPLIES 3

Capture.JPG

Thanks @terryhendicott  and @Werner_E . You guys are awesom..!!

 

REgards,

Ak

As Terry showed, the first two arguments of the "polyfit" function have to be vectors (= column vectors in Prime, n x 1 matrices).
Row vectors (1 x n matrices) are not seen as vectors in Prime!

 

Another error was that you tried to numerically evaluate (the = after the definition) this function.

You have also used unfavourable data, because your three points are collinear, which means that the polynomial function would only be linear, so the coefficient of the quadratic term would be zero. This would be no problem for Prime, of course. Nonetheless I changed your data slightly.

I also used X and Y for the data vectors so I have x free to be used in the plot.

polyfit returns a function you can use to evaluate at specific positions or to plot the graph of the function.

Werner_E_0-1737046920061.png

But polyfit will not display the function term! Maybe this was it you tried by adding the equal sign at the end.

 

To get the values of the coefficients you have to use the polyfitc function.

The second column of its result shows the coefficients, starting with the coefficient of x^0.

Of course we could also use these coefficients to define the polynomial function:

Werner_E_1-1737047196005.png

Prime 10 sheet attached

 

Announcements

Top Tags