필터 지우기
필터 지우기

How to get the equation for a cubic spline from cubic spline function?

조회 수: 11 (최근 30일)
Gina DiCarlo
Gina DiCarlo 2016년 10월 26일
댓글: farouk messaoud 2018년 10월 22일
Say I have two sets of data, x and y, such that
x = [1,2,3,4,5] y = [6,7,8,9,10]
t = linspace(1,5,100) Finding the cubic spline using the function:
splineX = spline(x,y,t);
I have used the command to be able to plot function splineXbut I'm not sure how I can find the actual equation the spline function calculates
(I know that for this data it would simply be a straight line but I only used this to better articulate what I'm trying to find)

답변 (1개)

David Goodmanson
David Goodmanson 2016년 10월 26일
Hello Gina, If you use spline in the form
pp = spline(x,y)
you will get a structure that contains all that information. pp.coefs is an nx4 matrix of polynomial coefficients for the intervals, in Matlab convention with the leftmost column containing the cubic coefficients and the rightmost column containing the constant coefficients. I'm not too good at structures so I usually use
[breaks coefs] = unmkpp(spline(x,y))
and get the coefficients that way.
  댓글 수: 1
farouk messaoud
farouk messaoud 2018년 10월 22일
hey; I have data to fit by cubic B-spline; How can I get the piecewise equations of the curves and the knot vector? thank you sir

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Splines에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by