Che310hw5 - y =[5 6 7 6 9 8 7 10 12 12 n = length(x calculate the length of the data set calculate statistics to be used later meanx = mean(x meany

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

View Full Document Right Arrow Icon
Ch E 310 – Fall 2008 - Homework 5 Solutions Problem 1 hw5_1.m x = 0.5; e = 1; while e >= 0.0000005; xold = x; f = (x/(1-x))*sqrt(7/(2+x)) - 0.04; df = 1/(1-x)*7^(1/2)*(1/(2+x))^(1/2)+x/(1-x)^2*7^(1/2)*(1/(2+x)). .. ^(1/2)-1/2*x/(1-x)*7^(1/2)/(1/(2+x))^(1/2)/(2+x)^2; x = x - (f/df); e = abs(x - xold)/x; end x Output: >> hw5_1 x = 0.0210 Problem 2 hw5_2.m h = 0.5; e = 1; r = 2; L = 5; V = 8.5; while e >= 0.0000005; hold = h; f = (r^2*acos((r-h)/r)-(r-h)*sqrt(2*r*h-h^2))*L - V; df = 20/(4*h-h^2)^(1/2)+5*(4*h-h^2)^(1/2)-5/2*(2-h)/(4*h-h^2)^(1/2)*. .. (4-2*h); h = h - (f/df); e = abs(h - hold)/h; end h Output: >> hw5_1 h = 0.7719
Background image of page 1

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

View Full DocumentRight Arrow Icon
Problem 3 hw5_3.m format compact % define the x and y data vectors x = [0 2 4 6 9 11 12 15 17 19];
Background image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: y = [5 6 7 6 9 8 7 10 12 12]; n = length(x); % calculate the length of the data set % calculate statistics to be used later meanx = mean(x); meany = mean(y); sumx = sum(x); sumy = sum(y); sumxy = sum(x.*y); sumx2 = sum(x.^2); sumy2 = sum(y.^2); % calculate the intercept and slope from the definitions in lecture 13 a = (n*sumxy-sumx*sumy)/(n*sumx2-sumx^2) b = meany-a*meanx % calculate the correlation coefficient r2 = (n*sumxy-sumx*sumy)^2/((n*sumx2-sumx^2)*(n*sumy2-sumy^2)) % plot the data and regression fit simultaneously plot(x,y, 'o' ); hold on fplot(@(x) a*x+b,[0 20]) hold off Output: a = 0.3525 b = 4.8515 r2 = 0.8368 2 4 6 8 10 12 14 16 18 20 4 5 6 7 8 9 10 11 12...
View Full Document

This homework help was uploaded on 03/26/2008 for the course CHEM E 310 taught by Professor Clapp during the Fall '07 term at Iowa State.

Page1 / 2

Che310hw5 - y =[5 6 7 6 9 8 7 10 12 12 n = length(x calculate the length of the data set calculate statistics to be used later meanx = mean(x meany

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