Help with an Assignment.

2 views (last 30 days)
John Marshall
John Marshall on 11 Oct 2015
Commented: Walter Roberson on 11 Oct 2015
Down below is the code I have been working it is to display true or false through a series of if/else statements to determine the correct output. I am relatively new to matlab and any help in determining the reason that the output is not being display would be great. Thank you very much.
Var_1 = input('Enter age');
Var_2 = input('Enter Gender');
Var_3 = input('Enter chest pain type');
Var_4 = input('Enter resting blood pressure');
Var_5 = input('Enter Serum cholestoral');
Var_6 = input('Enter Fasting blood sugar');
Var_7 = input('Enter resttin ECG results');
Var_10 = input('Enter ST depression induced by exercise relative to rest');
Var_12 = input('Enter number of major vessels');
Var_13 = input('Enter heart condition');
if Var_3 <=3 && Var_10 <= 1.9 && Var_1 <=56
disp('False')
elseif Var_1 > 56 && Var_2 <= 0 && Var_1 <= 59
disp('True')
if Var_3 <= 3 && Var_10 <= 10 && Var_1 > 56 && Var_2 <= 0 && Var_1 > 59;
disp('False')
elseif Var_2 > 0 && Var_5 > 245
disp('True')
if Var_3 <= 3 && Var_10<=1.9 && Var_1 > 56 && Var_2 > 0 && Var_5 <= 245 && Var_6 <= 0 && Var_12 <= 0
disp('False')
elseif Var_12 > 0
disp('True')
if Var_3 <= 3 && Var_10 <= 1.9 && Var_1 > 56 && Var_2 > 0 && Var_5 <= 256 && Var_6 > 0
disp('False')
elseif Var_10 > 1.9 && Var_7 <= 1
disp('True')
if Var_3 <= 3 && Var_10 > 1.9 && Var_7 > 1 && Var_1 > 59
disp('True')
elseif Var_1 <= 59
disp('False')
if Var_3 > 3 && Var_13 > 3
disp('True')
elseif Var_13 <= 3 && Var_12 > 0 && Var_2 > 0
disp('True')
if Var_3 > 3 && Var_13 <= 3 && Var_12 > 0 && Var_2 <= 0 && Var_11 > 1
disp('True')
elseif Var_11 <= 1
disp('False')
if Var_3 > 3 && Var_13 <= 3 && Var_12 <= 0 && Var_4 > 145
disp('True')
elseif Var_4 <= 145
disp('False')
end
end
end
end
end
end
end
end
  4 Comments
Image Analyst
Image Analyst on 11 Oct 2015
Have you tried stepping through the code with the debugger and examining why you're not going into the "if" block?
Walter Roberson
Walter Roberson on 11 Oct 2015
We readers do not know what the various codes are. For example we do not know which of the more than 83 genders code as 1, which one as 2, which one as 3, and so on. Give us a specific set of inputs.
For example it is obvious that your code will fail if you enter multiple values for some of the inputs, so we need to know exactly what you are entering.

Sign in to comment.

Answers (1)

Eng. Fredius Magige
Eng. Fredius Magige on 11 Oct 2015
Hi Its work just enter at least one data

Categories

Find more on Numerical Integration and Differential Equations in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!