lagran

# lagran - end%V is the vector for the coefficients of the...

This preview shows page 1. Sign up to view the full content.

function [C, L] = lagran(X,Y)  %Input - X is a vector that contains a list of  abscissas  % - Y is a vector that contains a list of  ordinates  %Output - C is the a matrix that contains the coefficients of   %    the Lagrange interpolatory polynomial  % - L is the a matrix that contains the Lagrange coefficient  %    polynomials  w=length(X);  n=w-1;  L=zeros(w,w);  %Form the Lagrange coefficient polynomials  for k=1:n+1 %for each of (n+1) polynomials  defined by Eqn. (10.14)  on page 534       V=1;       for j=1:n+1          if k~=j          V=conv(  V, poly(X(j))  )/(  X(k) - X(j)  );               %multiply n-terms of (x-X(j))/(X(k)-X(j)) for j~=k
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: end %V is the vector for the coefficients of the polynomial (10.14) end L(k,:)=V; %k-th raw of L stores (n+1) coefficients of the polynomial (10.14) end %Determine the coefficients of the Lagrange interpolating polynomial C=Y*L; %columns 1, 2,, n, n+1 of L represent coefficients of , ,x, 1 terms % of the polynomials (10.14) %C, as a vector, represents the coefficients of the Lagrange polynomial...
View Full Document

## This note was uploaded on 09/11/2011 for the course MECH 231 taught by Professor Den during the Spring '11 term at Rutgers.

Ask a homework question - tutors are online