Hi,
The lines "n(i,j) = n(i,j) * (x(j) - t(k))" & "d(i,j) = d(i,j) * (t(i) - t(k))" are leading to the error in the code. The number of columns in the first matrix doesnot match with the number of rows in the second matrix which will lead to error in matrix multiplication. There seems to be a for loop missing which you may refer below.
for i = 1:n+1
for j = 1:length(x)
n(i,j) = 1;
d(i,j) = 1;
for k = 1:n+1
if i ~= k
n(i,j) = n(i,j) * (x(j) - t(k));
d(i,j) = d(i,j) * (t(i) - t(k));
end
end
l(i,j) = n(i,j)/d(i,j);
end
end