Spline and PPL discrete points

6 vues (au cours des 30 derniers jours)
Dhruv Tripathi
Dhruv Tripathi le 21 Mar 2020
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.

Réponse acceptée

David Goodmanson
David Goodmanson le 21 Mar 2020
Modifié(e) : David Goodmanson le 21 Mar 2020
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

Plus de réponses (0)

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by