function [ e ] = func_Spline3_Eval( n, t, y, z, x )
%FUNC_SPLINE3_EVAL Evalunate the value of x using Spline Methods
%       Inputs
%   n = # of intervels = knots -1
%   t = the array of "x" point values
%   y = the array of "y" point values
%   z = the Coeficients for the spline
%   x = the "x" value to evalunate at
%       Outputs
%   e = the evaluated value at x

i = n;
ex = 0;
while i > 1 && ex == 0;
    if (x-t(i)) >= 0;
        ex = 1;
    else
        i = i - 1;
    end    
end

h = t(i+1) - t(i);
tmp = (z(i)/2) + (x - t(i))*(z(i+1) - z(i))/(6*h);
tmp = -(h/6)*(z(i+1) + 2*z(i)) + (y(i+1) - y(i))/h + (x - t(i))*tmp;
e = y(i) + (x-t(i))*tmp;

end

