using max function without conditional function
이전 댓글 표시
how using max function, logical operators and comparison operators to write a code that if a number larger than 100, then return the difference between thwo values, and this number smaller than 100 then return 0.
댓글 수: 6
KSSV
2020년 8월 29일
It is very simple what have you tried?
Maria
2020년 8월 29일
Rik
2020년 8월 29일
That is enough. An else would make more sense, but you can use two if statements with opposite conditions. So let me repeat the question: what have you tried?
the cyclist
2020년 8월 29일
@Maria: Part of the reason for asking to see what you have tried is that it helps understand how much MATLAB you know, see how close you are to solving the problem, and see how much effort you have put in yourself.
Without knowing those things, we don't know how much help you need, and we might waste a lot of your time and ours.
Maria
2020년 8월 29일
dpb
2020년 8월 29일
As this is obviously homework, it's not kosher to just provide the answer ... but hint: look at
답변 (1개)
Walter Roberson
2020년 8월 29일
0 개 추천
A > B implies A - B > 0 . Which implies that the maximum of (A-B) and (0) is (A-B).
A < B implies A - B < 0. Which implies that the maximum of (A-B) and (0) is (0).
카테고리
도움말 센터 및 File Exchange에서 Programming에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!