Calculate inflection point of spline
6 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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 :
pp=spline(deep,temp);
I generate the spline; with :
[x,C,l,k,d]=unmkpp(pp);
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);
or
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
M
0 Kommentare
Antworten (1)
Siehe auch
Kategorien
Mehr zu Splines finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!