from
Gaussian forward Interpolation formula
by Aman Gaur
This MATLAB code computes the desired data point within a given range.
|
| gaussian_forward_interpolation.m |
N=input('Enter the number of variables ');
for i=1:N
x(i)=0;
end
for i=1:N
x(i)= input('Enter the values of x ');
end
x_des=input(' Enter the desired value of y ');
fin=N;
n=fin;
h=x(2)-x(1);
if rem(N,2)==0
N=N/2+1;
else
N=N/2+0.5;
end
p=(x_des-x(N))/h;
for i=1:fin
yp(i)=0;
end
for i=1:fin
y(i)= input('Enter the corresponding values of y with respect to x ');
end
for i= 1:n
for j=1:(n-1)
y_arr(i,j)=0;
end
end
for i= 1:n
for j=1:(n)
k_arr(i,j)=0;
end
end
for i=1:n
k_arr(i,1)=y(i);
end
i=1;
b=2;
while i<(fin+1) %pending
j=2;
c=1;
while j~=(n+1) %y1
k_arr(c,b)=(k_arr(j,i)-k_arr(j-1,i));
j=j+1;
c=c+1;
end
i=i+1;
n=n-1;
b=b+1;
end
fact(1)=1;
fact(2)=p;
fact(3)=(p*(p-1));
fact(4)=((p+1)*p*(p-1));
init=fact(4);
er=p-2;
if(fin>4)
inc=0;
for i=5:fin
fact(i)=init*er;
init=fact(i);
er=er-1;
end
end
for i=1:fin
perm(i)=factorial(i);
end
ans=0;
c=1;
bck=N;
fig=N;
for i=1:(fin-1)
ans=ans+(fact(i+1)*k_arr(fig,(i+1)))/perm(i);
c=c+1;
if c==2
fig=fig-1;
c=0;
end
end
ans=ans+k_arr(bck,1);
|
|
Contact us