MATLAB question Write a function to compute the following 2d

MATLAB question:

Write a function to compute the following 2-dimensional function f(x,y):

Set f to be zero for other conditions of x and y. The function should include x and y as number inputs. Use elseif statements.

2T 2y or T 0 y 0 f(r,y) -2a 2y or a 0 y 2 0 f 2y f S 0 y 0 or T 2a y or z 0 y S 0

Solution

function z=f(x,y)
if(x>=0&&y>0)
z=(2*x)+(2*y)
elseif(x<=0&&y<0)
z=(-2*x)+(-2*y)
elseif(x>0&&y<=0)
z=(2*x)+(-2*y)
elseif(x<0&&y>=0)
z=(-2*x)+(2*y)
else
z=0
end
end


f(2,2)
f(-2,2)
f(-2,-2)
f(2,-2)

MATLAB question: Write a function to compute the following 2-dimensional function f(x,y): Set f to be zero for other conditions of x and y. The function should

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site