BME Cheat Sheet Test 1

BME Cheat Sheet Test 1 - Q=D/(C*t)=D/(int(C(t)dt,t,a,b) /...

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

View Full Document Right Arrow Icon
Q=D/(C*t)=D/(int(C(t)dt,t,a,b)) /// C*t is area under curve; alternatively C=D/V where V=Q*T /// note Q is same as R Rectangular Approx: R(f;P) = h * SUM[f(x i ),1,n-1] /// Trap Approx: T(f;P) = h/2*(f(x 1 )+f(x n ))+h*SUM[f(x i ),2,n-1] /// Simpson: S(f;P) = h/3 * [f(x 1 ) + 4f(x 2 ) + 2f(x 3 ) + 4f(x4) + 2f(x 5 ) + …2(f(x n-2 ) + 4f(x n-1 ) + f(x n )] /// note n must be odd, if n is even do first or last step w/ trapezoidal rule Cubic Spline: for S1: [a,b] and S2: [b,c] /// S 1 (x)=…, S 1 (x)=…, S 2 (x)=…, S 2 (x)=…, S 1 (b)=S 2 (b), S 1 (b)=S 2 (b), S 1 (a)=0, S 2 (c)=0 Euler’s: x(t+h) = x(t) + h*f[x(t),t] RK2: k 1 =h*f[x(t),t] /// k 2 =h*f[x(t)+k 1 /2, t+h/2] /// x(t+h)=x(t)+k 2 Euler’s for n diff eqs: x i (t+h) = x i (t) + h*f i [x 1 (t),…,x n (t),t)] …where x i (0), i=1,…,n RK2 for n diffeq: k1 i = h*f[(x 1 (t),x 2 (t),…,x n (t),t] /// k2 i =h*f i [x 1 (t)+k1 1 /2,…x n (t) +k1 n /2,t+h/2) /// x i (t+h)=x i (t)+k2 i Matlab Approx’s: function calc_cardiac_output(filename) data = load(filename); % pull out time and dye vectors from data file t = data(:,1); dye = data(:,2); h = t(2)-t(1); % sampling interval % calculate area under curve R = h*sum( dye(1:end-1) ); % rectangular T = h*( (dye(1)+dye(end))/2 + sum(dye(2:end-1)) ); % trapezoidal S = h/3*( dye(1)+dye(end)+4*sum(dye(2:2:end-1))+2*sum(dye(3:2:end-2)) ); % simpson's Z = trapz(t,dye); % matlab built-in trapezoidal D = input('Enter amount of dye injected (mg): '); % area is in mg*s/L so D/area will give us L/s, multiply by 60 to get L/min Q_R = D/R*60; Q_T = D/T*60; Q_S = D/S*60; Q_Z = D/Z*60; % print results disp(sprintf('Area approximations (mg*s/L):\nRectangular = %3.3f\tTrapezoidal = %3.3f\tSimspon''s rule = %3.3f\ttrapz = %3.3f\n',R,T,S,Z)) disp(sprintf('Cardiac output estimates (L/min):\nRectangular = %1.4f\tTrapezoidal = %1.4f\tSimspon''s rule = %1.4f\t\ttrapz = %1.4f\n',Q_R,Q_T,Q_S,Q_Z)) % plot gh = figure; plot(t,dye,'ko') title(['Dye concentration (', filename, ')']) xlabel('Time (s)') ylabel('Concentration (mg/L)') axis([0 32 0 34]) % change font sizes for readable saved figures set(findall(gh,'Type','text'),'FontSize',14) set(findall(gh,'Type','axes'),'FontSize',14) % save figure for report print('-dmeta',[filename, '.emf']) Matlab Recirc function recirc_correction data = load('dyerecirc.dat');
Background image of page 1

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

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 03/30/2010 for the course BME 210 taught by Professor D'argenio during the Spring '07 term at USC.

Page1 / 2

BME Cheat Sheet Test 1 - Q=D/(C*t)=D/(int(C(t)dt,t,a,b) /...

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