BME210_HW_1

# BME210_HW_1 - fprintf('The approximation to the area under...

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

% rectangular load('dye.dat') y=dye(:,2); h=dye(2,1)-dye(1,1); totdye=sum(y); n=length(y); totdye=totdye-y(n); area=h*totdye; method1=area; m %trapezoidal approximation method2=(h/2)*(y(1)+y(n))+(totdye-y(1))*h; m %Trapz method3=trapz(y); m % simpson's rule odd=y(3:2:30); even=y(2:2:30); sumodd=sum(odd)*2; sumeven=sum(even)*4; method4=(y(1)+y(31)+sumodd+sumeven)*(h/3); m % Enter the amount of dye input mass_of_dye = input(' Enter the amount of dye input in mg: '); m %Calculate the cardiac output for 4 methods Q1 = mass_of_dye*60/method1; Q2 = mass_of_dye*60/method2; Q3 = mass_of_dye*60/method3; Q4 = mass_of_dye*60/method4; % Output fprintf('The approximation to the area under the dye concentration curve by the method of rectangular(units of mg-sec/L) is %6.3f\n', method1 ) fprintf('The approximation to the area under the dye concentration curve by the method of trapezoidal(units of mg-sec/L) is %6.3f\n', method2 )
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: fprintf('The approximation to the area under the dye concentration curve by the method of function trapz(units of mg-sec/L) is %6.3f\n', method3 ) fprintf('The approximation to the area under the dye concentration curve by the method of simpson(units of mg-sec/L) is %6.3f\n', method4 ) m fprintf('The cardiac output calculated from the method of rectangular in L/min is %3.3f\n', Q1 ) fprintf('The cardiac output calculated from the method of trapezoidal in L/min is %3.3f\n', Q2 ) fprintf('The cardiac output calculated from the method of function trapz in L/min is %3.3f\n', Q3 ) fprintf('The cardiac output calculated from the method of simpson in L/min is %3.3f\n', Q4 ) % plot(y, 'o') xlabel('Time in second') ylabel('Concentration of dye in the sampled blood solution') title('Dye concentration-time data') axis([0.0 32.0 0 34]) %%%%%%%%%%...
View Full Document

## This note was uploaded on 09/15/2011 for the course BME 210 at USC.

Ask a homework question - tutors are online