Develop debug and test a matlab program to implement Languag

Develop, debug, and test a matlab program to implement Language interpolation. Base it on the pseudocode from Fig 18.11 (provided below). Test it by duplicating Example 18.7. (Provided below).

Please help !

Figure 18.11 is here:

http://imageshack.com/a/img921/894/tJPZSx.png

Example 18.7 is here:

http://imageshack.com/a/img924/7704/yJW74v.png

Solution

Answer:

Lagrance interpolation function: lanrng.m

--------------------------------------------

%function implementation for langrange interpolation
%value of n should be passed as n+1.
function sum=lagrng(x,y,n,xx)
sum=0;
for i=1:n
    product=y(i);
    for j=1:n
      if i~=j
        product=(product*(xx-x(j)))/(x(i)-x(j));
      end
    end
    sum=sum+product;
end
%lagrng=sum;
end

------------------------------------------------

Test code as per given example: See the code below - lagrng_test.m

------------------------------------------------

%test code for lagrng
s=[1 3 5 7 13]; %time instances in seconds
v=[800 2310 3090 3940 4755]; %measured velocity in cm/s
t=10; %time at which velocity is to be estimated

%initial values
s0=0;
v0=0;

%test vectors of n+1 data points
s_test=[s0 s];
v_test=[v0 v];

%number of data points
n=length(s_test);

%performing lagrane interpolation
v=lagrng(s_test,v_test,n,t);
disp(v);

---------------------------------------

Develop, debug, and test a matlab program to implement Language interpolation. Base it on the pseudocode from Fig 18.11 (provided below). Test it by duplicating
Develop, debug, and test a matlab program to implement Language interpolation. Base it on the pseudocode from Fig 18.11 (provided below). Test it by duplicating

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site