Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function plotSpline(coeff, x, y)
- plot(x,y,'or');
- hold on;
- n=size(coeff,1);
- s1 = @(t) coeff(1,1)*(t-x(1)).^3 + coeff(1,2)*(t-x(1)).^2 + coeff(1,3)*(t-x(1)) + coeff(1,4)
- x1 = (x(1)-1):0.001:x(2);
- plot(x1,s1(x1));
- for i=2:n-1
- s = @(t) coeff(i,1)*(t-x(i)).^3 + coeff(i,2)*(t-x(i)).^2 + coeff(i,3)*(t-x(i)) + coeff(i,4)
- %S(i) = s;
- xx=x(i):0.001:x(i+1);
- plot(xx,s(xx));
- end
- sn = @(t) coeff(n,1)*(t-x(n)).^3 + coeff(n,2)*(t-x(n)).^2 + coeff(n,3)*(t-x(n)) + coeff(n,4)
- xn = x(n):0.001:(x(n)+2);
- plot(xn,sn(xn));
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement