function sol = coefficient(x,D) dim = size(D); n = dim(1) ; a = x; b = D; for i = 1:n-1 tempc(i) = 3*(x(i+1) - x(i)) - 2*D(i) - D(i+1); tempd(i) = 2*(x(i) - x(i+1)) + D(i) + D(i+1); end tempc(n) = 3*(x(1)-x(n)) - 2*D(n) - D(1); tempd(n) = 2*(x(n) - x(1)) + D(n) + D(1); c = tempc'; d = tempd'; sol = [d c b a];