BME210_HW_1

BME210_HW_1 - method of function trapz(units of mg-sec/L...

This preview shows pages 1–2. 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 ) fprintf('The approximation to the area under the dye concentration curve by the

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: 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]) %%%%%%%%%% x=dye(:,1);y=dye(:,2); xx=[0:0.1:30]; yy=spline(x,y,xx); plot(x,y,'o',xx,yy,'-')...
View Full Document

{[ snackBarMessage ]}

What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern