Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

New to MATLAB?

Calculate inflection point of spline

Asked by Max

Max (view profile)

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




Max (view profile)


No products are associated with this question.

1 Answer

Answer by Max

Max (view profile)

on 20 Nov 2012

Any opinion?



Max (view profile)

Contact us