MATLAB: Spline and PPL discrete points

splspline

I am given data sets v and r to spline over an interval and graph. I have to use spline and ppl intervals to accomplish this however when I do this the spline is nothing like the data plot.

Best Answer

Hi Dhruv.
your choice of a = 0.125 is kind of messing things up, because it's well above where the data ends. If you go only to the end of the data as in figure 2, the results are more sensible. Also,
spY = spline(v,r,XX);
is simpler than the two commands involving polyval.
a = .125;
sp = spline(v,r);
XX = linspace(0,a,100);
spY = ppval(sp, XX);
figure(1)
plot(v,r,'o',XX,spY);
grid on
a = max(v);
sp = spline(v,r);
XX = linspace(0,a,100);
spY = ppval(sp, XX);
figure(2)
plot(v,r,'o',XX,spY);
grid on