Hi Abiageal,
As per the information provided in the question, I understand that you are facing issues in implementing 'Newton's Divided Differences Function' as you are getting 'B' a matrix of all zeros.
This is because in the 'Newton's Divided Differences Function' we need to initialize the first row of 'divided differences table'.
You can try initialising the first row with the help of this code.
x=1:10;
y= 11:20;
ans=dividediffs(x,y)
function [B] = dividediffs(x,y)
%DIVIDEDDIFFS computes the divided differences of an array of (x,y) points
% INPUT: two arrays of x and corresponding y values OUTPUT: divided differences
n = length(x);
B = zeros(n,n);
B(:, 1) = y';
if n == 1
B = y(1);
else
for k = 2:n
for i = 1: n-k+1
if (i+k) <= n
B(i,k) = (B(i+1,k-1)-B(i,k-1))/(x(i+k)-x(i));
end
end
end
end
end
Hope this resolve your query!