P16_1 - f a1 = y(1,i a b1 =(y(1,i 1...

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

View Full Document Right Arrow Icon
function P16_1 f x = [1 2 2.5 3 4 5]; x y = [1 5 7 8 2 1]; y h1 = x(1,2) - x(1,1); h h2 = x(1,3) - x(1,2); h h3 = x(1,4) - x(1,3); h h4 = x(1,5) - x(1,4); h h5 = x(1,6) - x(1,5); h h = [h1 h2 h3 h4 h5]'; h b21 = (y(1,2)-y(1,1))/(x(1,2)-x(1,1)); b b32 = (y(1,3)-y(1,2))/(x(1,3)-x(1,2)); b b43 = (y(1,4)-y(1,3))/(x(1,4)-x(1,3)); b b54 = (y(1,5)-y(1,4))/(x(1,5)-x(1,4)); b b65 = (y(1,6)-y(1,5))/(x(1,6)-x(1,5)); b A = [1 0 0 0 0 0; h1 2*(h1 + h2) h2 0 0 0; 0 h2 2*(h2 + h3) h3 0 0; 0 0 h3 2*(h3 + h4) h4 0; 0 0 0 h4 2*(h4 + h5) h5; 0 0 0 0 0 1]; b = [0; 3*(b32 - b21); 3*(b43 - b32); 3*(b54 - b43); 3*(b65 - b54); 0]; b c = A\b; c hold on h for i = 1:5
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
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: f a1 = y(1,i); a b1 = (y(1,i+1) - y(1,i))/(h(i,1)) - (h(i,1)/3)*(2*c(i,1) + c(i+1,1)); b c1 = c(i,1); c d1 = (c(i+1,1) - c(i,1))/(3*h(i,1)); d X = (x(1,i):0.1:x(1,i+1))'; X f1 = a1 + b1.*(X - x(1,i)) + c1.*(X - x(1,i)).^2 + d1.*(X - x(1,i)).^3; f %plot(x, y, 'o', X,f1) % end e %-------------------------------------------------------------------------% xx = (0:0.1:6); x yy = spline(x,y,xx); y %plot(x,y,'o',xx,yy) % %-------------------------------------------------------------------------% xi = (0:0.01:6); yi = interp1(x,y,xi); plot(x,y,'o',xi,yi) p...
View Full Document

This note was uploaded on 09/21/2011 for the course EGM 3344 taught by Professor Raphaelhaftka during the Spring '09 term at University of Florida.

Page1 / 2

P16_1 - f a1 = y(1,i a b1 =(y(1,i 1...

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

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