hw11_p05b

# hw11_p05b - sum = sum 4*y2(2*j 2*y2(2*j 1 end sum = sum...

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

clc clear r = [0.0, 2.5, 5.0, 7.5, 10.0, 12.5, 15.0, 17.5, 20.0]; % Radius (cm) r = 0.01*r; % Unit conversion to (m) v = [0.914, 0.890, 0.847, 0.795, 0.719, 0.543, 0.427, 0.204, 0.0]; % Velocity (m/s) n = length(r); h = 0.025; R1 = 0.0; R2 = 0.2; % 2nd order polynomial regression: y = a0 + a1*x + a2*x^2 x = r; y = v; y y2 = 2.0*pi*x.*y; y sum = 0.0; for j=1:(n-3)/2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: sum = sum + 4*y2(2*j) + 2*y2(2*j+1); end sum = sum + y2(1) + 4*y2(n-1) + y2(n); Q = h/3*sum; Q % open file fid4 = fopen('hw11_p05_answer.txt','a'); % 'wt' means "write text" if (fid4 < 0) error('could not open file "hw11_p05_answer.txt"'); end; e fprintf(fid4, 'Simpson''rule: '); fprintf(fid4, 'Q = %10.5f m^3/s\n', Q); fclose(fid4);...
View Full Document

{[ snackBarMessage ]}

Ask a homework question - tutors are online