Skip to main content
1-Visitor
August 12, 2014
Solved

Including units with the polyfit function

  • August 12, 2014
  • 1 reply
  • 1753 views

Hello all,

I am a fairly new user of Mathcad. I have a question about utilizing units with the polyfit function. I have experimental data relating temperature pressure and density. I wrote a program which needs to look up the density as a function of pressure and temperature. The original data was in excel, it had several curves for a few temperatures as a function of pressure.The data was very linear and the curves were fairly parallel, so i took the linear regression curves from excel and brought them into mathcad. I then created a program which allowed me to choose a temperature, it would then choose the two curves which the chosen temperature was between and linearly interpolated between the two points. I got this program to work with units and is the top portion of the attached file.

I thought there must be a better way, so I decided to try the polyfit function. I imported the test data and utilized the polyfit function to "fill in" the holes in my data and create a polynomial to describe the surface. I could not get the polyfit function to work with units. The polyfit is a much more elegant solution. Both approaches give very close results but I was wondering if anyone else was having this same type of problem?

The reason I need the units to work out is because I reference this calculation in a program. I apologize but I can not attach the program.

Thanks in advance for any help/ insight.

Best answer by RichardJ

The polyfit function works fine with units. The problem is that the 3D plot will not accept units on the x or y axes (lame, but true).

1 reply

RichardJ19-TanzaniteAnswer
19-Tanzanite
August 12, 2014

The polyfit function works fine with units. The problem is that the 3D plot will not accept units on the x or y axes (lame, but true).

1-Visitor
August 12, 2014

Thank you, I should have seen that.