Problem with interpolation #482
-
Greetings; I have a problem with interpolation. Given the following set of data (Renold's number vs Drag coeff.). How to find the drag coefficient for ex, Re = 270000. I understood that interpolation is done in calcpad using the index of the element inside the array. However, the reuired Re is not inside of the array and usually it lies between 2 values. Re = 11366.13396 Cd = 1.146401985 |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
Hi @MohamedMostafaShehata! Nice to see you on GitHub! Yes, they are discrete values, but Calcpad includes linear and spline interpolation functions: l Below is the complete working code you can use:
|
Beta Was this translation helpful? Give feedback.
-
Thanks Net, it works perfectly. BTW, I have installed V.7.1.8, it is amazing. Great work |
Beta Was this translation helpful? Give feedback.
Hi @MohamedMostafaShehata! Nice to see you on GitHub!
Yes, they are discrete values, but Calcpad includes linear and spline interpolation functions: l
ine(x; y_values)
andspline(x; y_values)
, respectively. You have to put your data instead ofy_values
and it will become a continuous function.You should do that for both Re and Cd by defining the functions:
Re_lin(x) = line(x; Re)
Cd_lin(x) = line(x; Cd)
'Then, find x for your Reinolds number Re0 = 27000' by using the following command
x0 = $Find{Re_lin(x) - Re0 @ x = 1 : len(Re)}
'And finally extract the corresponding Cd value
Cd0 = Cd_lin(x0)
Below is the complete working code you can use: