This preview shows page 1. Sign up to view the full content.
Unformatted text preview: function takes the nodes and the corresponding function values as inputs. It
outputs four column vectors “a,b,c,d” that store the coeﬃcients ai , bi , ci , di for i =
1, 2, . . . , n − 1 of the spline. The function starts with
function [a,b,c,d] = ncspline(x,f)
3. The next line extracts the number of nodes from the input “x” and store the value in
the variable “n”.
n = length(x);
2 4. The following lines convert “x” and “f” to column vectors.
x = x(:);
f = f(:);
5. The next line computes the spacings hi = xi+1 − xi for i = 1, 2, . . . , n − 1 and stores
them in a column vector “h” of length n − 1.
h = x(2:n) - x(1:n-1);
6. Recall that the linear system to solve is tridiagonal. Next, construct an n × 3 matrix
“D” that stores only the entries of the three di...
View Full Document
This document was uploaded on 10/10/2013.
- Fall '13
- Numerical Analysis