n 1 of the spline the function starts with function

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

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 coefficients 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

{[ snackBarMessage ]}

Ask a homework question - tutors are online