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.

 Akzeptierte Antwort

Andrei Bobrov
Andrei Bobrov am 23 Mai 2012

0 Stimmen

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 Kommentar

cupuyc a
cupuyc a am 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]

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by