Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

MATLAB Assignment 2 Goals: - Learn matrix manipulation. - Use different built-in

ID: 3573688 • Letter: M

Question

MATLAB Assignment 2 Goals: - Learn matrix manipulation. - Use different built-in functions. - Learn basic plotting. 1. Create a script and name it _MatLab_2.m, and save it on the desktop Part 1: 2. Create row vector A with the following values: 31, 29, and 27 3. Create column vector B with the following values: 4.2, 1.8, and 1.8 4. Find the VECTOR product of B times A and save the result in variable C. Imagine you ran a study on 3 different human subjects and desire to calculate the cardiac output of each individual. Let each of the three columns of matrix C represent the data of a different patient. Let row 1 of C represent the End Diastolic Volume (EDV, which is the amount of blood present in the left ventricle when it is filled with blood in mL) of each patient. Likewise, let row 2 of C represent the End Systolic Volume (ESV, which is the amount of blood remaining inside the ventricle after it has contracted in mL). Finally, let the last row of C represent the heart rate (HR) of each patient. In order to calculate the cardiac output, the following formulas are used: Stroke Volume=EDV-ESV Cardiac Output=HR*Stroke Volume 5. By using indexing, retrieve the first row of C only and save it in a variable called EDV. 6. By using indexing, retrieve the second row of C only and save it in a variable called ESV. 7. By using indexing, retrieve the third row of C only and save it in a variable called HR. 8. Create a new vector SV and set it equal to the difference of EDV and ESV. 9. Create a new vector called CO and set it equal to the ELEMENT-WISE product of HR and SV. Heart rate, stroke volume, and cardiac output rise as a person starts to exercise and continue to rise as the intensity of the activity increases. Repeat steps 2 – 9, with the following A and B vectors. They represent the same 3 human subjects during and at the end of an intense exercise. (Hint: do not overwrite your results!) During exercise: A changed to 32, 30 and 28, and B changed to 5.2, 2.2, and 1.8. At the end of exercise: A changed to 33, 31 and 27, and B changed to 6.2, 2.4, and 2.2. 10. Create two figures, one for the stroke volume and one for the cardiac output. figure(1); figure(2); 11. One the same figure, plot the stroke volume for each on the subjects before, during, and after exercise (Stroke volume should be in mL) 12. Use a different color for each subject, label your axis, and add a title and a legend) 13. Repeat step 11 and 12 for the cardiac output (Cardiac output should be in L/min). 13. Which human subject seems to in a better shape?

Explanation / Answer

function [p1]=patient(A,B)
    C=B*A
    EDV=C(1,:)
    ESV=C(2,:)
    HR=C(3,:)
    SV=EDV-ESV
    for i=1:4
        CO(i)=SV(i)*HR(i)
    plot(SV,CO);
    legend('before','during','after')
    grid on
    title('patient results')
end
[c1]=patient([31,29,27],[4.2;1.8;1.8])
[c2]=patient([32,30,28],[5.2,2.2;1.8])
[c3]=patient([33,31,27],[6.2;2.4;2.2])