using max function without conditional function

2 Ansichten (letzte 30 Tage)
Maria
Maria am 29 Aug. 2020
Beantwortet: Walter Roberson am 29 Aug. 2020
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 Kommentare
Maria
Maria am 29 Aug. 2020
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 am 29 Aug. 2020
As this is obviously homework, it's not kosher to just provide the answer ... but hint: look at

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Walter Roberson
Walter Roberson am 29 Aug. 2020
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).

Kategorien

Mehr zu MATLAB finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by