cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Your Friends List is a way to easily have access to the community members that you interact with the most! X

Curve fitting/Interpolation question

Cornel
18-Opal

Curve fitting/Interpolation question

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

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Werner_E
24-Ruby V
(To:Cornel)

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

View solution in original post

16 REPLIES 16
Fred_Kohlhepp
23-Emerald I
(To:Cornel)

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

Werner_E
24-Ruby V
(To:Cornel)

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

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

 

 

@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

 



Werner_E
24-Ruby V
(To:Cornel)



Cornel_4-1710947490121.png

....

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

Cornel_0-1710947888648.png

You have just shown these constants yourself when you symbolically evaluated the function.

You also see it when you evaluate R1 and tau

 

If you use the shifted function where a0=R0 is the resistance for 0°C, then a0=R0=4.85 kOhm and a1=-1/tau=1/27.317 K =-0.0366 / K

But the function must be written as a0*e^(a1*(Temp-0°C)).

If you insist on a0*e^(a1*Temp) then you have to use the values shown in my first sheet, where R0=a0 is the resistance at absolute zero (0 Kelvin).

 

And for this:

Cornel_0-1710945438349.png

 

Oh, yes, thank you both. 

@Werner_E LIKE THIS: its without units

Cornel_0-1710949879614.png

Cornel_1-1710949888350.png

See attached Mathcad prime 9 file.

 

 

Update sheet - see attached MCP9. This is somewhat bad, look what much error there is at low temperature:

Cornel_0-1710951185002.png

For the remaining two its ok:

Cornel_1-1710951257038.png

Cornel_0-1710951333794.png

 

 

 

 

@Werner_E Update: I found where mistake was:
Initially:

Cornel_1-1710951806793.png

Cornel_2-1710951815194.png

Cornel_3-1710951823257.png

 

Now, how to include units in my sheet? @Werner_E 

@Werner_E Here is my approach. Please let me know your thoughts and if you find another way...Mathcad Prime 9 file attached. Its strange with this K (Kelvin), and that Mathcad doesn't let it do operations directly in degrees celsius, and display in degrees celsius..For example

Cornel_0-1710955162192.png
This is for -10 degree Celsius

Cornel_1-1710955192665.png

Cornel_2-1710955207334.png

 

Werner_E
24-Ruby V
(To:Cornel)

My sheets used units anyway - what was wrong with them?

 

I would prefer the approach in the attached sheet

ttokoro
20-Turquoise
(To:Cornel)

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

Attache the sheet..

ttokoro
20-Turquoise
(To:Cornel)

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.

Top Tags