lagrange - L(i,:) = L(i,:).*(xx-x(j))/(x(i)-x(j)); end end...

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

View Full Document Right Arrow Icon
function yy = lagrange(x, y, xx) n = size(x,2); L = ones(n,size(xx,2)); L if (size(x,2)~=size(y,2)) fprintf('\nERROR!\nX and Y must have the same number of elements\n'); yy = NaN; else for i = 1:n for j = 1:n if (i~=j) % calculation of Langrange basis polynomial
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: L(i,:) = L(i,:).*(xx-x(j))/(x(i)-x(j)); end end end yy = 0; for i = 1:n % Calculation of interpolated yy values, i.e. L(x) yy = yy+y(i)*L(i,:); end end %%% if (size(x,2)~=size(y,2))...
View Full Document

This note was uploaded on 11/16/2009 for the course ENGIN 7 taught by Professor Horowitz during the Spring '08 term at Berkeley.

Ask a homework question - tutors are online