Question

In: Statistics and Probability

3. Write a Matlab script that describes the dynamics of Pressure and Flow in the systemic...

3. Write a Matlab script that describes the dynamics of Pressure and Flow in the systemic arteries and Left Ventricle. Assume that :

1) Pressure in the Left atrium (PLA) and in the Systemic Veins (Psv) remain constant.

2) A time dependent LV compliance

3) Opening/Closing of the heart valves instantaneously with the direction of flow (i.e. valves are at an open or closed states. Use parameter values from the handout.

Solutions

Expert Solution

/* define normal human, hemodynamic constants in 2-element Windkessel model */ pl = 72    /* cardiac cycles per minute */ s = 60/pl       /* period of cardiac cycle in seconds */ h = (2/5)*s    /* period of systole in seconds */ ml = 90      /* blood output to aorta or pulmonary artery per cardiac cycle in cm^3 */ /* define function for blood flow as variable amplitude sine wave */ fct i(t,q0) = q0*sin(pi*t/h) /* find peak amplitude of flow such that the total cardiac output is ml */ fct ampl() = root(z,0,1000,ml-integral(t,0,h,i(t,z))) q0 = ampl() /* define and compute flow for 3 cardiac cycles */ fct i1(t) = if ((tmd_mod(t,s)) 

The flow function, aortic pressure, and pulmonary pressure curves can be graphed with the following additional MLAB commands:

draw af left title "Blood Flow (ml/sec)" size .007 frame 0 to 1, .66 to .99 w1 = w draw ms left title "Aortic Pressure (mmHg)" size .007 frame 0 to 1, .33 to .66 w2 = w draw mp left title "Pulmonary Artery Pressure (mmHg)" size .007 frame 0 to 1, 0 to .33 view 

The view command causes the graphs shown below to appear on the computer display:

/* read (time,pressure)-ordered pairs from press.dat */ pdat = read(press,71,2)      /* format = 71 rows, 2 columns */ /* define function for blood pressure as linear interpolation into pdat, and compute pressure for 1 cardiac cycle */ fct p(t) = lookup(pdat,t) ap = points(p,0:pdat[71,1]!100) /* define function for arterial flow under 2-element Windkessel model */ fct i(t) = p(t)/r+c*p't(t) /* set r,c constants for systemic arterial system and compute aortic flow for 1 cardiac cycles */ r = .9000                /* systemic peripheral resistance in (mmHg/cm^3/sec) */ c = 1.0666              /* systemic arterial compliance in (cm^3/mmHg) */ mi = points(i,0:pdat[71,1]!100) /* draw aortic pressure and aortic flow */ draw ap draw pdat lt none pt crosspt ptsize .005 left title "Aortic Pressure (mmHg)" size .01 no framebox frame 0 to 1, 0 to .5 w1 = w draw mi left title "Aortic Flow (ml/sec)" size .01 frame 0 to 1, .5 to 1. no framebox view 

The following graph results:

/* read digitized from MOL.DAT: time in seconds in column 1, pressure in mmHg in column 2, flow in ml/sec in column 3. */ dt = read(mol,65,3) n = nrows(dt) tv = dt col 1                         /* time in seconds */ pdat = tv '(dt col 2)     /* time,pressure ordered pairs */ idat = tv '(dt col 3)         /* time,flow ordered pairs */ /* define flow function and evaluate for one cardiac cycle */ fct i1(t) = lookup(idat,mod(t,tv[n])) af = points(i1,0:tv[n]!100) /* define function for evaluating Akaike criterion given s=sum-of-squares, nd=number of data points, and np=number of parameters in model */ fct aic(s,nd,np) = nd*log(s)+2*np /* 2-element Windkessel model with rw = peripheral resistance and cw = arterial compliance. Calculate values for parameters following Molino et al: peripheral resistance = mean pressure/mean flow; arterial compliance = time constant/peripheral resistance, where time constant = .529 seconds. */ fct pw't(t) = (i1(t)-pw(t)/rw)/cw init pw(0) = pdat[1,2] rw = mean(pdat col 2)/mean(idat col 2) cw = .529/rw mw2 = points(pw,0:tv[n]!100) maxiter = 0 fit (cw), pw to pdat a[1] = aic(sosq,n,2) maxiter = 20 /* 3-element Windkessel model with rb1 = valve resistance, rb2 = peripheral resistance, and cb = arterial compliance */ fct pb't(t) = rb1*i1't(t)+((1+rb1/rb2)*i1(t)-pb(t)/rb2)/cb init pb(0) = pdat[1,2] rb1 = 0 rb2 = rw cb = cw fit (rb1), pb to pdat a[2] = aic(sosq,n,3) mb3 = points(pb,0:tv[n]!100) /* 4-element Windkessel model with lm = inertial mass of fluid, rm1 = valve resistance, rm2 = peripheral resistance, and cm = arterial compliance. */ fct pm't(t)=lm*i1''t(t)+(rm1+lm/(cm*rm2))*i1't(t)+((1+rm1/rm2)*i1(t)-pm(t)/rm2)/cm init pm(0) = pdat[1,2] rm1 = rb1 rm2 = rb2 cm = cb lm = 0          /* in grams/cm^4 */ constraints q1 = {lm > 0} fit (lm), pm to pdat constraints q1 a[3] = aic(sosq,n,4) mm4 = points(pm,0:tv[n]!100) /* draw graphs */ draw af draw idat lt none pt circle ptsize .005 left title "Flow (ml/sec)" size .01 frame 0 to 1, .66 to .99 no framebox w1 = w draw mw2 draw mw2 row 1:100:15 lt none pt triangle ptsize .01 draw mb3 draw mb3 row 1:100:15 lt none pt square ptsize .01 draw mm4 draw mm4 row 1:100:15 lt none pt star ptsize .01 draw pdat draw pdat row 1:n:2 lt none pt crosspt ptsize .01 left title "Pressure (mmHg)" size .01 title "Pressure data = +" at (.2,.85) ffract size .01 title "2-element = '27TC'R, AIC = "+a[1] at (.2,.8) ffract size .01 title "3-element = '27TB'R, AIC = "+a[2] at (.2,.75) ffract size .01 title "4-element = '27TE'R, AIC = "+a[3] at (.2,.7) ffract size .01 frame 0 to 1, 0 to .66 no framebox view plot in molwtp.ps 

The resulting graph is:


Related Solutions

9.) Write a MATLAB script that will read the Pressure and Temperature columns from the provided...
9.) Write a MATLAB script that will read the Pressure and Temperature columns from the provided Excel file. Use a loop to calculate the linear best fit line for the data. You may only use the built-in functions sum, size, and length. Plot both the individual data points (red) and the fit line (blue) on the same graph. Include a title and axes labels.
write a matlab script for double mass spring system with animation.
write a matlab script for double mass spring system with animation.
Part A: Write a MATLAB script to find the volume of the cylinder in gallons, as...
Part A: Write a MATLAB script to find the volume of the cylinder in gallons, as well as the tank dimensions in feet. Assume that the initial measurements are 7 meters in diameter and 11 meters tall. Display your final answers to the screen using disp and a statement without a semicolon, e.g. write the following into your script disp(‘The capacity in U.S. gallons is:’), capacity, where capacity is a variable that you defined in preceding calculations. Part B: In...
(MATLAB) Write a script that would create a 3x5 matrix of random integers and write this...
(MATLAB) Write a script that would create a 3x5 matrix of random integers and write this new matrix to a file called “Assignment3_Question5.dat”.
Using MATLAB or Octave, Write a script that prompts the user for the coordinates of three...
Using MATLAB or Octave, Write a script that prompts the user for the coordinates of three points A, B, and C, namely (xA, yA), (xB, yB), (xC, yC), forming a triangle, storing each in a variable (for a total of 6 variables). The script should then calculate the centroid G = (xG, yG) using xG = xA+xB+xC 3 and yG = yA+yB+yC 3 , storing each in a variable. Finally, the script should print all four points. Sample output: Enter...
using matlab Write a script that simulates a card game that works as follows: A dealer...
using matlab Write a script that simulates a card game that works as follows: A dealer places 5 cards face down on the table and flips the first card. The player goes down the line, one at a time, and guesses if the next card is higher or lower than the card displayed, and then the next card is revealed. In the end, the player is awarded a point for each correct guess. In terms of coding, your script should...
Write a MATLAB script or function that returns the required initial velocity of the ping pong...
Write a MATLAB script or function that returns the required initial velocity of the ping pong ball required to launch it a specified distance. Use projectile motion equations. Keep in mind that the initial firing height will change depending on the proposed catapult design. Primary considerations in the catapult design are accuracy and repeatability as groups will be tasked with hitting the target (cup) repeatedly at distances ranging from 7 to 9 ft. (cup moved in 6 in. increments).
MATLAB Write a script which asks the user of the program to provide an initial horizontal...
MATLAB Write a script which asks the user of the program to provide an initial horizontal position, initial vertical position, initial velocity, and angle. Create a time vector spanning from zero seconds to 100 seconds incremented at 0.01 seconds. Call the function that you created in the previous problem to calculate the trajectory and velocities of the projectile. Find the maximum height of the projectile and the time at which it reaches that point. Write a neat sentence stating what...
Using MATLAB or Octave, use documenting code to Write a script that prompts the user for...
Using MATLAB or Octave, use documenting code to Write a script that prompts the user for a minimum and maximum real number, then generates and prints a random number in the requested range. The script should then do the same for an integer range. Sample output: Enter a minimum real value: 0.5 Enter a maximum real value: 30 A random number in the range ( 0.5000, 30.0000 ) is 1.7851 Enter a minimum integer value: -10 Enter a maximum integer...
To find a positive root for , write a MATLAB script file that uses Bisection method....
To find a positive root for , write a MATLAB script file that uses Bisection method. Choose any initial value that is needed. Use absolute relative approximate error to be less than 0.01. Your code should report the number of iteration and the value of x.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT