Plotting f(x,y)= (x+y)/(y/100+x/50) Using MATLAB in Region -2x<y<=0

AI Thread Summary
To plot the function f(x,y)=(x+y)/(y/100+x/50) in the specified region of -2x<y<=0 using MATLAB, users can create a meshgrid for the desired x and y ranges. The suggestion includes applying masks to selectively display the valid region while removing unwanted portions, such as singularities along the line y=-2x. The example code provided demonstrates how to implement these masks effectively. By using logical conditions to filter the data, the plot can accurately represent the function within the defined constraints. This method allows for a clearer visualization of the function in the specified area.
shogun61
Messages
1
Reaction score
0
f(x,y)=\frac{(x+y)}{(y/100+x/50)}
how can i plot this function with MATLAB in the region restricted between y=-2x and x=0 lines?
i wanted to plot that the second region of the cartesian coordinate
x=-1:0.1:0;
y=-2*x+eps , eps is very small
[X,Y]=meshgrid(x,y);
z=(X+Y)./(X/100+Y/50);
surf(z)

but it is not what i want.is there another way to plot this?
 
Physics news on Phys.org
Why so hard? Just plot regular, then remove the region you don't want

Edit: What I mean is, you can create masks and use them to selectively crop out undesirable portions of your graph (e.g. the singularities that occur along the y=-2x line) Note that your viewport will still be rectangular

x = -2:0.1:2;
y = -2:0.1:2;
[X,Y] = meshgrid(x,y);
Mu = X < 0;
Ml = Y > -2*X;
surf(X,Y,double(z.*Mu.*Ml));

Hope this helps.
 
Last edited:
Back
Top