hw11_p03 - end e sum = sum*1.0e-3; % Unit conversion from...

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

View Full Document Right Arrow Icon
% Intervals are not constants. So the trapezoidal rule is appropriate. % clear all clc c Q = 0.3 * 60.0; % m^3/min t = [0, 1, 4, 6, 8, 12, 16, 20]; % Time (s) c = [12, 22, 32, 45, 58, 75, 70, 48]; % Position (mg/m^3) m_prime = Q*c; n = length(t); n plot (t, c); p range_a = [0 1]; r % Integration using the trapezoidal rule % sum = 0; for j=1:n-1 % Consider nonconstant intervals sum = sum + (t(j+1)-t(j))*0.5*(m_prime(j) + m_prime(j+1));
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: end e sum = sum*1.0e-3; % Unit conversion from 'mg' to 'g' % open file fid4 = fopen('hw11_p03_answer.txt','a'); % 'wt' means "write text" if (fid4 < 0) error('could not open file "hw11_p03_answer.txt"'); end; fprintf(fid4, '\nEstimated accumulated mass = %10.5f g\n', sum); fclose(fid4);...
View Full Document

This note was uploaded on 02/22/2010 for the course CHE 348 taught by Professor Chelikowsky during the Spring '08 term at University of Texas.

Ask a homework question - tutors are online