본문 바로가기

Enginius/Matlab

Spline Fitting

Spline fitting is widely used in vast applications such as what you already have in your mind... :)

In this post, I will show some examples of spline fitting based on excellent code provided by Jonas Lundgren <splinefit@gmail.com>. 


Basically, what is does is to find coefficients of some polynomials in some partitions of the input space. The boundary of each partition must be connected and smooth which serve as constraints in finding the coefficients. 


Following is an example of spline fitting using different orders. 

The input space is partitioned into 8 equally divided partitions. The whole function is modeled using piecewise polynomial structure provided by Matlab. (ppval is used)


One can also incorporate some constraints into the spline fitting such as fixing value of a function at certain point or fixing gradient of a function. (Actually I guess these are pretty much all it can do.) Anyway following is the result of a spline fitting given some constraints. 


Furthermore, it can be used as a robust regression algorithm which I am not that familiar with.. Nevertheless, the results are amazing. As optimizing coefficient is done using least square method, I guess robust least square methods are applied. 



Constraints are given as follows:

4 Constraints in spline fitting 

1.  y(0.0) is 1.0 

2. y'(0.0) is 1.0 

3.  y(6.3) is 2.0 

4. y'(6.3) is -1.0 


Demo code 


"the most important" splinefit function


Notes



'Enginius > Matlab' 카테고리의 다른 글

Fast implementation of kdpp  (0) 2015.04.02
Kinect 사용하기 2  (1) 2014.12.26
다각형과 선분 사이의 접점  (0) 2014.12.17
점과 다각형 사이의 거리  (0) 2014.12.15
Rename bunch of files in Matlab  (0) 2014.08.05