For this homework, you will write a single M-file that solves the problems descr
ID: 3713699 • Letter: F
Question
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 Problem 1. High Blood Pressure - If structures (50 points) 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: a) systolic 120; diastolic - 80; b) systolic 145; diastolic 80; c) systolic 137; diastolic 92; isHighBP should output a 0 isHighBP should output a 1 isHighBP should output a 1Explanation / 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));
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.