ASE 311 Extra Credit - >> yit = -10*exp(-2*xi).*xi +...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
ASE 311 Extra Credit 1.) function yia = implementation(xp,yp,xi) n = length(xp)-1; yia = 0; for i = 1 : n + 1 dk1 = yp(i); for k = 1 : n + 1 if (k~=i) dk1 = dk1./(xp(i) - xp(k)); end end yja = 0; for j = 1 : n + 1 if (j~=i) dk2 = 1; for k = 1 : n + 1 if dk2 = dk2.*(xi - xp(k)); end end yja = yja + dk2; end end yia = yia + ((dk1).* yja); end >> xp = [ 0.6 1.5 1.6 2.5 3.5 ]; >> yp = [ 0.9036 0.3734 0.3261 0.08422 0.01596 ]; >> xi = linspace(-0.6,3.5,291); >> yia = implementation(xp,yp,xi);
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 2
Background image of page 3
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: >> yit = -10*exp(-2*xi).*xi + 5*exp(-2*xi); >> plot(xi, yia, xi, yit) 0.5 1 1.5 2 2.5 3 3.5-0.7-0.6-0.5-0.4-0.3-0.2-0.1 Lagrange Interpolation Derivative Exact Solution Derivative 2.) >> xp = [ 0.6 1.5 1.6 2.5 3.5 ]; >> yp = [ 0.9036 0.3734 0.3261 0.08422 0.01596 ]; >> xi = linspace(0.6,3.5,291); >> yia = implementation(xp,yp,xi); >> yit= -10*exp(-2*xi).*xi + 5*exp(-2*xi); >> sqrt(trapz(xi, (yia-yit).^2)) ans = 0.0978...
View Full Document

This note was uploaded on 02/13/2010 for the course ASE 311 taught by Professor Kraczek during the Spring '08 term at University of Texas at Austin.

Page1 / 3

ASE 311 Extra Credit - >> yit = -10*exp(-2*xi).*xi +...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online