gauss forward interpolation method

8 views (last 30 days)
PJS KUMAR
PJS KUMAR on 18 Oct 2018
Edited: Torsten on 18 Oct 2018
I wrote the following code for gauss interpolation
function [ yval ] = gauss_p( xd,yd,xp )
n=length(xd);
if(length(yd)==n)
tbl=yd';
for j=2:n
for i=1:n-j+1
tbl(i,j)=tbl(i+1,j-1)-tbl(i,j-1);
end
end
tbl
h=xd(2)-xd(1);
if rem(n,2)==0
k=n/2+1;
else
k=n/2+0.5;
end
p=(xp-xd(k))/h
pt=cumprod([1,p-(0:n-3)])
dt=[tbl(k,1) tbl(k,2) tbl(k-1,3)+tbl(k-1,4) tbl(k-1,4)+tbl(k-1,5) tbl(k-1,5)+tbl(k-1,6) tbl(k-1,6)+tbl(k-1,7)]./factorial(0:n-2)
yval=sum(pt.*dt)
end
Suggest me to simplify the calculation of 'dt' vector subject to 'n' values

Answers (1)

Torsten
Torsten on 18 Oct 2018
Edited: Torsten on 18 Oct 2018
dt = [tbl(k,1), tbl(k,2), tbl(k-1,3:n-1)-tbl(k-1,4:n)]./factorial(0:n-2)
?
Best wishes
Torsten.

Categories

Find more on Interpolation in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!