MATLAB Answers


Calculate inflection point of spline

Asked by Max
on 19 Nov 2012

Hi, I have to calculate the inflection point of a cubic spline.

I have 2 vectors that contains experimental data; - temperature - - > temp = [t1 t2 t3 ... tn ] - deepness (depth); - - > deep 0 [d1 d2 d3 ... dn]

with :


I generate the spline; with :


I extrapolated the coefficient of spline in the C matrix: ervery rows represents a interpolating polynomial ( f(x) = ax^3 + bx^2 + cx + d);

To identify the inflection point, I calculate (first the first derivatives and then) the second derivative of the spline coefficients ( the polynomial derivatives is f''(x) = 6ax + 2b )

Cder=bsxfun(@times,C(:,1:end-1), 3:-1:1);

Cder2 = bsxfun(@times,Cder(:,1:end-1), 2:-1:1);


CoefDer2 = [6*C(:,1) 2*C(:,2)];

Cder2 = mkpp(x,CoefDer2);

However, then, I impose f''(x)=0 and calculate all polynomials roots

xCder2 = cell2mat(arrayfun(@(X) roots(Cder2(X,:)), (1:size(Cder2,1)),'un',0))';

Now in xCder2 there are memorized all the x-components of the inflection points.

Then, I calculate the y-component of the with:

yCder2 = cellfun(@(xtipo,ytipo) polyval(xtipo,ytipo), num2cell(C,2), num2cell(xCder2));

Finally, I join the two-component-vector in single points with

Points=num2cell([xCder2, yCder2],2); [p1,p2,p3,p4,p5,p6,p7]=deal(Points{:});

Is my execution correct? Thanks a lot



Log in to comment.

1 Answer

Answer by Max
on 20 Nov 2012

Any opinion?


Log in to comment.

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Win prizes and improve your MATLAB skills

Play today