Forward Difference Table in MATLAB | M-file

Code :


delx=5
x=45:delx:65;
y=[2.8710,2.4040,2.0830,1.8620,1.7120];
n=5;
for i=1:n
    diff(i,1)=y(i);
end
for j=2:n
    for i=1:n-j+1
        diff(i,j)=diff(i+1,j-1)-diff(i,j-1);
    end
end
fprintf('\n******forward difference formula table****');
fprintf('\n\tx\t    y\t        del1\t     del2\t    del3\t    del4');
for i=1:n
    fprintf('\n   %.f',x(i));
    for j=1:n-i+1
        fprintf('\t   %.4f',diff(i,j));
    end
end


Free Codes: youtube.com/castorclasses Free Support: castorclasses2014@gmail.com Live Support: t.me/matlabirawen Like us: https://www.facebook.com/matlabirawen Join us: https://www.facebook.com/groups/MATLA... MATLAB Book for the beginner: https://amzn.to/3fTfmTa

No comments