Mathcad - Curve Fitting Cubic Spline - ODTÜ Web Servisiusers.metu.edu.tr/ender/Mathcad - Curve...
Transcript of Mathcad - Curve Fitting Cubic Spline - ODTÜ Web Servisiusers.metu.edu.tr/ender/Mathcad - Curve...
Mathcad Tutorial on Curve Fitting - Cubic Spline
N 20 Δx 0.15i 0 N f x( ) sin 2.5 x( ) 1.2 x
vxi i Δx vyi f vxi
0 1 2 30
1
2
3
4
vy
vx
Cubic Spline Fit
vs cspline vx vy( ) g x( ) interp vs vx vy x( )
vs pspline vx vy( ) h x( ) interp vs vx vy x( )
vs lspline vx vy( ) j x( ) interp vs vx vy x( )
0 1 2 30
2
4
6
8
vy
g x( )
h x( )
j x( )
vx x
Middle East Technical University, METU, Ankara/TURKEY
1
Dr. Ender CİĞEROĞLU
Mathcad Tutorial on Curve Fitting - Cubic Spline
Regression Fit by Linear Combination of Functions
F x( )sin 2.5 x( )
x
V linfit vx vy F( ) V1
1.2
k x( ) V F x( )
0 1 2 30
1
2
3
4
5
vy
k x( )
vx x
F x( )sin 2.2 x( )
x
V linfit vx vy F( ) V0.934
1.306
l x( ) V F x( )
0 1 2 30
2
4
6
vy
k x( )
l x( )
vx x
Differentiation and Integration of Data Sets
After cubic spline fitting we have an analytical equation for the function in terms of3rd order polynomials, for which we can calculate the derivative or which we can
Middle East Technical University, METU, Ankara/TURKEY
2
Dr. Ender CİĞEROĞLU
Mathcad Tutorial on Curve Fitting - Cubic Spline
p yintegrate.
0 1 2 32
0
2
4
Exact DerivativeDerivative from Spline Fit
xf x( )
d
d
xg x( )
d
d
x
0
π
2
xf x( )
d 2.1632833726 Numerical Integration of Exact Function
0
π
2
xg x( )
d 2.1632800248 Numerical Integration of Spline Fitted Function
Middle East Technical University, METU, Ankara/TURKEY
3
Dr. Ender CİĞEROĞLU