Get Help

Turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- Community
- :
- PTC Mathcad
- :
- PTC Mathcad
- :
- Need help understanding Syntax of linfit function?

Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Highlighted

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

06-08-2017
09:49 AM

06-08-2017
09:49 AM

Dear Community:

I am a very new user of MathCad, and I need help understanding the syntax of the linfit function. (At least I think it's a syntax issue).

I built a small worksheet to look at various curve fitting functions (it grew out of a need from a work related worksheet; I have hand entered some of the data and changed to units to make the example sheet self-contained). I successfully parroted the linfit example for a quadratic fit (a*x^2+b*x+c), but I could not extend it successfully for a cubic fit (a*x^3+b*x^2+cx+d). I could successfully build a cubic fit using polyc.

I enclose the worksheet:

Page 1: Data

Page 2: Cubic Spline

Page 3: Straight Line

Page 4: Quadratic linfit (and polyc)

Page 6: Cubic linfit (and polyc) <---- This is where it goes wrong

Any insights would be appreciated.

Regards,

Bob

Solved! Go to Solution.

1 ACCEPTED SOLUTION

Accepted Solutions

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

06-09-2017
11:29 AM

06-09-2017
11:29 AM

Thank you for your answers. However, I am still perplexed. I have enclosed a PDF of my worksheet for those with Prime 3.

Page 6, from the PDF is repeated here:

(ps, qres) are x,y values. I print out the coefficients from both linfit and polyc (they come out in reverse order, but you can look at the units to compare). The coefficients for x^3 and x^2 are arguably zero. But the linear and constant terms are very, very different. This difference is plotted on page 7 (reproduced here):

The results from polyc seem reasonable, those from linfit do not.

I *think* that I'm using the correct syntax - but clearly that isn't so!

Regards,

Bob

5 REPLIES 5

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

06-08-2017
10:02 AM

06-08-2017
10:02 AM

Re: Need help understanding Syntax of linfit function?

I can't open your file, so I can't see what you did. But this is linfit in Prime 3.0:

If we knew that the linear term wasn't there, we could modify the function:

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

06-09-2017
03:42 AM

06-09-2017
03:42 AM

Re: Need help understanding Syntax of linfit function?

This document is for Mathcad Prime **4.0** version.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

06-09-2017
11:29 AM

06-09-2017
11:29 AM

Thank you for your answers. However, I am still perplexed. I have enclosed a PDF of my worksheet for those with Prime 3.

Page 6, from the PDF is repeated here:

(ps, qres) are x,y values. I print out the coefficients from both linfit and polyc (they come out in reverse order, but you can look at the units to compare). The coefficients for x^3 and x^2 are arguably zero. But the linear and constant terms are very, very different. This difference is plotted on page 7 (reproduced here):

The results from polyc seem reasonable, those from linfit do not.

I *think* that I'm using the correct syntax - but clearly that isn't so!

Regards,

Bob

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

06-12-2017
01:27 PM

06-12-2017
01:27 PM

Re: Need help understanding Syntax of linfit function?

Hi Robert,

Are you still having the issue or has it been solved?

I see you have marked your last post as correct, but within, your text hints that you are still having the issue.

Thank you for clarifying.

Best,

Toby

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

06-12-2017
01:32 PM

06-12-2017
01:32 PM

Re: Need help understanding Syntax of linfit function?

I can duplicate this exact problem in Prime 3.0, Linfit gives an incorrect response.

I think you found a bug!

Note that "polyfit" (without the "c") will create a function: Y := poltfit (ps,qres,3) then Y(pres)= will give the function evaluated at "pres". But you probably already knew that! 😉