I have to calculate divided differences, for vector x and vector y(which is function value of vector x). Divided difference is get when substracting two consecutive y elements, and then dividing that difference with two consecutive x elements. My function has to return vector that consists only of first elements of each divided difference. Here is my code, but not working.(So if we have vector x=[x1, x2, x3, ..., xn] this function has to return vector [f[x1], f[x1,x2],f[x1,x2,x3],...,f[x1,x2,...,xn]].
function div = evalDiv(x,y)
difference(i) = (temp(i)-temp(i-1))/(x(i)-x(i-(j-1));
test = evalDiv([ 1 2 3 4],[5 6 7 8]);