필터 지우기
필터 지우기

using max function without conditional function

조회 수: 4 (최근 30일)
Maria
Maria 2020년 8월 29일
답변: Walter Roberson 2020년 8월 29일
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에서 Programming에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by