Generating C1 class function with hermit interpolation?

2 views (last 30 days)
Firstly thanks for all reply.
Problem: I want to generate a c1,c2,c3 class polinom(function,curve) with hermite interpolation. Given: a, b begining and end of my function. y(a),y(b), y'(a),y'(b),y''(a),y''(b),y'''(a),y'''(b). Example: http://dl.dropbox.com/u/27560194/picture.jpg
How i can do this in matlab?
Thank you, very much.

Accepted Answer

Walter Roberson
Walter Roberson on 2 Nov 2011
You have 8 constraints, so you need a polynomial with 8 coefficients, which is a 7th degree polynomial. So construct
syms c1 c2 c3 c4 c5 c6 c7 c8
syms x
Y = sym('x->c1*x^7+c2*x^6+c3*x^5+c4*x^4+c5*x^3+c6*x^2+c7*x+c8');
Now let the constraint values be C01, C02, C11, C12, C21, C22, C31, C32 -- which I numbered with the continuity order as the first digit and the second digit is 1 for "a" and 2 for "b".
syms C01 C02 C11 C12 C21 C22 C31 C32
Now we make use of the symbolic operator D to express the constraints:
ics = '{Y(a)=C01,Y(b)=C02,D(Y)(a)=C11,D(Y)(b)=C12,D([1,1],Y)(a)=C21,D([1,1],Y)(b)=C22,D([1,1,1],Y)(a)=C31,D([1,1,1],Y)(b)}';
and expand the polynomial function and allow the D expressions to be evaluated:
eqnsys = simplify(subs(ics,'Y',Y));
And what we have left is a simple system of equations that we can solve() for:
S = solve(eqnsys,C01,C02,C11,C12,C21,C22,C31,C32);
SS = structfun(@simplify, S, 'Uniform', 0);
And now you will have SS.c1, SS.c2 and so on, in symbolic form, expressed in terms of C01, C02, etc.
  3 Comments
Walter Roberson
Walter Roberson on 3 Nov 2011
So rename variables if they bother you.
The above code already accounts for the continuity. Polynomials are continuously differentiable, and your question specifically asked for a "polynomial" to be built, so this code builds the minimum polynomial that satisfies the derivative conditions at the given locations. Whether you call the derived coefficients c1, c2, c3, c4, c5, c6, c7, c8, or Marcia, Carol, Greg, Jan, Peter, Cindy, Mike, and Bobby, really does not matter.
Here, allow me to make the only necessary change to the code shown:
Y = sym('x->Marcia*x^7+Carol*x^6+Greg*x^5+Jan*x^4+Peter*x^3+Cindy*x^2+Mike*x+Bobby');
Now you will have SS.Marcia, SS.Carol, and so on, in symbolic form, expressed in terms of C01, C02, etc.

Sign in to comment.

More Answers (0)

Categories

Find more on Polynomials in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!