Cubic Spline Interpolation and Plotting??? Question inside

조회 수: 2 (최근 30일)
Nicole Bonino
Nicole Bonino 2015년 9월 25일
편집: WAT 2015년 9월 25일
Use cubic splines to fit the data bellow. Repeat the calculation but now set the derivatives at the end points to zero. Compare the two profiles.
x=[0 2 4 7 10 12]; y=[20 20 12 7 6 6];
pp=spline(x,y)
This is the code I have so far but I keep getting an error when trying to plot it. I tried plotting using this code:
plot(x,pp,y) and again with plot(pp,x,y) and plot(x,y,pp)
the output I get for pp is:
form: 'pp'
breaks: [0 2 4 7 10 12]
coefs: [5x4 double]
pieces: 5
order: 4
dim: 1
But I keep getting error messages. I tried following the examples in the doc but it isn't working.
  댓글 수: 3
Nicole Bonino
Nicole Bonino 2015년 9월 25일
I had my code in before, I dont know why it didnt save. I fixed it.
WAT
WAT 2015년 9월 25일
편집: WAT 2015년 9월 25일
Read the documentation for spline()
You're using the form of the function which takes only two input arguments, which returns the coefficients for the spline functions. You can't plot coefficients, you need to plot function values.

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

답변 (1개)

WAT
WAT 2015년 9월 25일

카테고리

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