In the code below I'm trying to produce the following summation notation with the answers expected being 1,-2,1 (second derivative,central finite difference coefficient)
However when I run my code the answer for S = NaN, and I'm a bit lost as to where I've gone wrong.
n = 2;
k = n/2;
S = 0;
if (m~=j) && (m~=i)
if (l~=j) && (l~=i) && (l~=m)
Any help much appreciated, thanks in advance.