hw7_solutions

# hw7_solutions - MAE 107 Spring 2007 HW 7 Problem 1 This...

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

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

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: MAE 107 Spring 2007 HW 7 Problem 1 This code interpolates the given data for the conductivity-temperature function, and evaluates this function at x = 4. Contents Setup (a) Forward Difference Table (b) Construct Newton-Gregory Polynomial (c) Using Direct MATLAB Commands Optimal fit Setup clear; close all ; clc % input data point h = 0.4; % data interval % temperature x = 1:h:5; % conductivity f = [1.210 1.1968 1.2999 1.4378 1.6183 1.849 2.1376 2.4919 2.9194 3.427 4.025]; (a) Forward Difference Table n = size(x,2); % data poi nts (=11) % construct the table table(1,:) = x; table(2,:) = f; for i = 3:n+1 table(i,1:n-i+2) = diff(table(i-1,1:n-i+3)); %diff(c)=[c(2)-c(1), c(3)-c(2), ..., c(n)- c(n-1)] end fprintf( 'The forward difference table:\n' ) table = table'; disp(table) The forward difference table: Columns 1 through 9 1.0000 1.2100 -0.0132 0.1163 -0.0815 0.0893 -0.0895 0.0898 -0.0901 1.4000 1.1968 0.1031 0.0348 0.0078 -0.0002 0.0003 -0.0003 -0.0001 1.8000 1.2999 0.1379 0.0426 0.0076 0.0001 -0.0000 -0.0004 0.0005 2.2000 1.4378 0.1805 0.0502 0.0077 0.0001 -0.0004 0.0001 0.0042 2.6000 1.6183 0.2307 0.0579 0.0078 -0.0003 -0.0003 0.0043 0 3.0000 1.8490 0.2886 0.0657 0.0075 -0.0006 0.0040 0 0 3.4000 2.1376 0.3543 0.0732 0.0069 0.0034 0 0 0 3.8000 2.4919 0.4275 0.0801 0.0103 0 0 0 0 4.2000 2.9194 0.5076 0.0904 0 0 0 0 0 4.6000 3.4270 0.5980 0 0 0 0 0 0 5.0000 4.0250 0 0 0 0 0 0 0 Columns 10 through 12 0.0900 -0.0894 0.0925 0.0006 0.0031 0 0.0037 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 (b) Construct Newton-Gregory Polynomial x0 = 1; % in order to have degree 10 polynomial, one has to start at x0 = 1 s = (4-x0)/h;...
View Full Document

## This note was uploaded on 06/02/2008 for the course MAE 107 taught by Professor Rottman during the Spring '08 term at UCSD.

### Page1 / 11

hw7_solutions - MAE 107 Spring 2007 HW 7 Problem 1 This...

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

View Full Document
Ask a homework question - tutors are online