Skip to main content
19-Tanzanite
March 20, 2024
Solved

Curve fitting/Interpolation question

  • March 20, 2024
  • 3 replies
  • 7918 views

Hi,

How to find a function that fits to below data. This function is a resistance temperature dependent that will be further involved into another equation (Vout(Temp)), and then how to plot Vout(Temp) vs Temp? Temp is temperature, lets say from -60degC to 90degC. Mathcad Prime 9 fille attached.

Cornel_1-1710938208277.png

Cornel_2-1710938238713.png

 

 

Best answer by Werner_E

As Fred already noticed you mixed up angle degree with degree temperature, presumably °C.

Werner_E_1-1710942571696.png

Now you have the choice between an interpolation (the "curve" runs exactly through the given points) or a curve fit, where you choose a function type and Prime tries to adjust the parameters so the overall failure is minimal (least square sum).

The simplest interpolation sure is the linear interpolation:

Werner_E_2-1710942808691.png

 

You may also try a spline interpolation which sometimes is appropriate but sometimes leads to undesired effects

Werner_E_3-1710943161931.png

 

As for a function fit you first would have to decide for a specific function type. Fred decided for a polynomial.
I guessed that an exponential fit might be appropriate. I use the generic "genfit" function for demonstration, but fo a simple exponential fit you may also use the built-in "expfit" function ("expfit" will also accommodate for a vertical displacement).

Note that the standard unit for temperature is Kelvin and its always a good idea to leave it at that because working with temperatures may be quite nasty using °C. So R0 is the resistance at the absolute zero (0 K) and thats the reason for the huge guess value of 100MOhm.

You also can see by the calculation to the right of the first plot that the curve does not run through the points exactly but rather fits them best.

Werner_E_5-1710943831103.png

 

Prime 9 sheet attached

3 replies

23-Emerald I
March 20, 2024

Attached is an Express 4.0 sheet.  A place to start, obviously not quite the right function.

Werner_E25-Diamond IAnswer
25-Diamond I
March 20, 2024

As Fred already noticed you mixed up angle degree with degree temperature, presumably °C.

Werner_E_1-1710942571696.png

Now you have the choice between an interpolation (the "curve" runs exactly through the given points) or a curve fit, where you choose a function type and Prime tries to adjust the parameters so the overall failure is minimal (least square sum).

The simplest interpolation sure is the linear interpolation:

Werner_E_2-1710942808691.png

 

You may also try a spline interpolation which sometimes is appropriate but sometimes leads to undesired effects

Werner_E_3-1710943161931.png

 

As for a function fit you first would have to decide for a specific function type. Fred decided for a polynomial.
I guessed that an exponential fit might be appropriate. I use the generic "genfit" function for demonstration, but fo a simple exponential fit you may also use the built-in "expfit" function ("expfit" will also accommodate for a vertical displacement).

Note that the standard unit for temperature is Kelvin and its always a good idea to leave it at that because working with temperatures may be quite nasty using °C. So R0 is the resistance at the absolute zero (0 K) and thats the reason for the huge guess value of 100MOhm.

You also can see by the calculation to the right of the first plot that the curve does not run through the points exactly but rather fits them best.

Werner_E_5-1710943831103.png

 

Prime 9 sheet attached

25-Diamond I
March 20, 2024

Addendum:

If you feel like me uncomfortable with the guess value at 0 Kelvin you may use a slightly different function which is shifted by 0°C. Now R0 is the resistance a 0°C which can be guessed from the given data to be around 5 kOhm.

Werner_E_7-1710944563355.png

 

 

Cornel19-TanzaniteAuthor
19-Tanzanite
March 20, 2024

@Werner_E What will be the value for 

Cornel_0-1710947366948.png

Cornel_4-1710947490121.png

 

Cornel_3-1710947457047.png

 


Werner I need the function R1(Temp)...what are the constants a0 and a1:

Cornel_0-1710947888648.png

 



ttokoro
21-Topaz I
21-Topaz I
April 1, 2024

Using your  data, I try to curve fitting by below functions.

ttokoro_0-1712013382652.png

 

 

image.png

At first I made interpolate data by log(time).

image.png

Then try to use expfit, polyfit, genfit, etc..

 

image.pngimage.pngimage.png

Finally, rationalfit can fit both magnitude and phase data.

ttokoro_1-1712013750598.png

 

image.pngimage.pngimage.png

t.t.
Cornel19-TanzaniteAuthor
19-Tanzanite
April 2, 2024

Attache the sheet..

ttokoro
21-Topaz I
21-Topaz I
April 2, 2024

I still study Rational Function Regression. You can find it by Mathcad help. 

rationalfit(vx, vy, conf, m, n, [Stdy], [LBUB], [Acc], ["noscale"])

 

m=5 and n=5 are OK to fit well.

t.t.