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

use Matlab For this homework, you will write a single M-file that solves the pro

ID: 3799494 • Letter: U

Question

use Matlab

For this homework, you will write a single M-file that solves the problems described below. Separate your solution to each problem with a cell block (use % % followed by a brief description of the problem). Use comments when appropriate. Remember to publish your code as a PDF file and submit both the PDF file and the M-file on Blackboard. Solve the following problems: Create a function called isHighBP, that accepts 2 input variables: systolic and diastolic, that represent a user's systolic and diastolic blood pressures, respectively. The function should return 1 output variable: TFHighBP, which will have a value of true if the systolic and diastolic pressures represent a blood pressure associated with hypertension. Hypertension is defined as a systolic blood pressure greater than or equal to 140 mmHg OR a diastolic blood pressure greater than or equal to 90. In your script, test the following cases: systolic = 120: diastolic = 80; isHighBP should output 0 systolic = 145: diastolic = 80; isHighBP should output a 1 systolic = 137: diastolic = 92; isHighBP should output a 1

Explanation / Answer

FUNCTION:-


function TFHighBP = isHighBP(systolic,diastolic) %define function isHighBP
  
TFHighBP=0; %default TFHighBP to 0

if(systolic>=140 | diastolic >= 90)
TFHighBP=1; %change the value of TFHighBP if condition if high bp meets
end
  

end

Script:-

fprintf('Systolic = 120; diastolic=80 isHighBP=%d ',isHighBP(120,80));
fprintf('Systolic = 145; diastolic=80 isHighBP=%d ',isHighBP(145,80));
fprintf('Systolic = 137; diastolic=92 isHighBP=%d ',isHighBP(137,92));