using max function without conditional function

2 次查看(过去 30 天)
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 个评论
Maria
Maria 2020-8-29
if num>100
output= num-100
if num<=100
output=0
This is conditional function, but I cannot use conditional function to solve this. Only logical and comparsion or max function
dpb
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
Walter Roberson 2020-8-29
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).

类别

Help CenterFile Exchange 中查找有关 MATLAB 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by