How do I find the derivative of a spline curve in MATLAB 7.9 (R2009b)?
Show older comments
I am trying to find a derivative of a spline using a POLYDER function. The result looks wrong.
x=[0 600 1000 1381 1887 3087 4265 5367 6267 6987 ; 40 100 100 200 200 800 700 349 400 40];
pp=spline(x(1,:),x(2,:));
xx=linspace(x(1,1),x(1,10),2000);
erg=ppval(pp,xx);
plot(xx,erg,'k');
hold on
[breaks,coefs,l,k,d] = unmkpp(pp);
pp2 = mkpp(breaks,repmat(k-1:-1:1,d*l,1).*coefs(:,1:k-1),d);
y_der=polyder(ppval(pp2,linspace(x(1,1),x(1,10),2000)));
plot(linspace(x(1,1),x(1,10),2000-1),y_der,'r');
Accepted Answer
More Answers (0)
Categories
Find more on Splines 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!