Else if Question with function

조회 수: 3 (최근 30일)
Hiba Azwar
Hiba Azwar 2017년 6월 1일
댓글: Hiba Azwar 2017년 6월 2일
??
Write a program to evaluate the function f (x, y) for any two values x and y, where the function f (x, y) is defined as follows; f (x, y) = x+y if x and y are greater than or equal to 0, f (x, y) = x+y^2 if x is greater than or equal to 0 and y is less than 0, f (x, y) = x^2+y if x is less than 0 and y is greater than or equal to 0 and f (x, y) = x^2+y^2 if x and y are less than 0.

채택된 답변

ES
ES 2017년 6월 1일
편집: ES 2017년 6월 1일
Check
function
if
elseif
To start with
function op = f(x,y)
if (x>=0 && y>=0)
op=x+y;
elseif(x>=0 && ...
....%If you want to deserve your marks, you should fill this up!
....
end
edited output to op.
  댓글 수: 3
Walter Roberson
Walter Roberson 2017년 6월 1일
You assign to a variable op but do not do anything with it afterwards.
You do not assign to the output variable output so it would not be possible to call the function in a context that used the output.
Hiba Azwar
Hiba Azwar 2017년 6월 2일
Thanks!!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Annotations에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by