Help with an Assignment.
2 次查看(过去 30 天)
显示 更早的评论
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 个评论
Image Analyst
2015-10-11
Have you tried stepping through the code with the debugger and examining why you're not going into the "if" block?
Walter Roberson
2015-10-11
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.
回答(1 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Numerical Integration and Differential Equations 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!