Hey guys.

So I've only ever used matlab for simple matrix multiplication, and I've never written a program with inputs and outputs and loops and such. I tried looking for samples online, but I couldn't find anything I was able to understand.

I tried writing the following program:

Code:

`function [ y ] = divdif( n,x,y )`

for j=1:n

d(j)=y(j)

end

for i=2:n

for j=1: n-i

d(i*n+j)=(d((i-1)*n+(j+1))-d((i-1)*n+j))/(x(j+i)-x(j))

end

y(i)=d(i*n+0)

end

(x and y are supposed to be vectors of length n, hence the input data. Same for d.)

But it's not working. Any suggestions on how to fix it?

Thanks!