Question

1. Write a code to draw a ‘mesh graph of following function f(x,y)= xy x > 0, y 0 xy2 x 20, y = 0 x<0, y=0 (x?y2 x <0, y < 0

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Matlab Program:

clear
clc
close all
% assuming x and y data
X=-5:5;
Y=-5:5;
% mesh grid
[x,y]=meshgrid(X,Y);
[m,n]=size(x);
f=zeros(m,n);
for i=1:m
for j=1:n
if x(i,j)>=0 && y(i,j)>=0
f(i,j)=x(i,j)*y(i,j);
elseif x(i,j)>=0 && y(i,j)<=0
f(i,j)=x(i,j)*y(i,j)^2;
elseif x(i,j)<0 && y(i,j)>=0
f(i,j)=x(i,j)^2*y(i,j);
elseif x(i,j)<0 && y(i,j)<0
f(i,j)=x(i,j)^2*y(i,j)^2;
end
end
end
% graph
mesh(x,y,f)

Screenshot:

1 I 4 5 - 6 8 - 10 11 - clear clc close all $ assuming x and y data X=-5:5; Y=-5:5; mesh grid [x, y]=meshgrid(X,Y); [m, n]=si

Save the above program and execute it.

Result:

I hope this will help you.

Add a comment
Know the answer?
Add Answer to:
1. Write a code to draw a ‘mesh' graph of following function f(x,y)= xy x >...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT