how to calculate spline of the function?

Hi. How can i obtain a cubic spline coefficients, if i know values and derivatives of the function? For example:
args = [-1, 0, 1];
vals = [-1, 0, 1];
derivs = [3, 0, 3];
subic_spline_coefs = ...?
I'd like obtain coefs using derivatives information.

 Réponse acceptée

Andrei Bobrov
Andrei Bobrov le 23 Mai 2012
X = [args;args]
Y = [vals;derivs]
P = spapi(4,X(:),Y(:))
after comment
ppp = csape([-1 1],[3 -1 1 3],[1 1])
eg
polyval(ppp.coefs,1)

1 commentaire

cupuyc a
cupuyc a le 23 Mai 2012
It work. Unfortunately, I can't understand which principle.
For the function y = x^3 I'd like to obntain the following coefficients: [1 0 0 0]
But I've obtained:
knots: [-1 -1 -1 -1 -0.3333 0.3333 1 1 1 1]
coefs: [-1 -0.3333 0.1111 -0.1111 0.3333 1]

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by