%title:- to find a funcational value of a discrete function at any %arbitrary pont using lagrange's interpolation %develope by:binod dhami %date:2080/03/28 %____________________three critical statement______________ close all; clear variables; clc; %__________________user I/P section_________________________ x=input('enter the value for x[]='); y=input('enter the value for y[]='); while(length(x)~=length(y)) clc; disp('x and y must be equal length'); x=input('enter the value for x[]='); y=input('enter the value for y[]='); end; out=[x,y]; disp(out); X=input('enter the value of x at which y is to be found x='); %_____________________Calculation Section______________ Y=0; n=length(x); for i=1:n temp=1; for j=1:n if i~=j temp=temp*(X-x(j))/(x(i)-x(j)); end; end Y=Y+temp*y(i); end %__________________Ouput section__________________ result=strcat('the value of y at X=',num2str(X),'is Y=',num2str(Y)); disp('__________________________'); disp(result);