Graphing $f(x,y) = x / (x^2 + y^2)$ in matlab

97 Views Asked by At

I have been having trouble plotting the following in MatLab:

$$f(x,y) = \frac{x}{x^2 + y^2}$$

I seem to have no trouble plotting similar functions (using a meshgrid). In fact, if I just try plotting $z = x^2 + y^2$, I don't run into any issues. Why is that that when I try to put an x in the numerator that things fall apart? I have also tried plotting with GeoGebra, but have had no luck.

Is there a way to plot this in MatLab? I am learning how to calculate tangent planes, and I would like to see visual representations of my work to confirm that I am arriving at correct conclusions.

1

There are 1 best solutions below

3
On BEST ANSWER

Using the following commands we will get the required plot:

  1. Initializing - $x = -20:1:20; \ y = -20:1:20$.
  2. Creating grid - $[X,Y] \ = \ \text{meshgrid}(x,y);$
  3. Ploting - $\text{mesh}(X./(X.^2+Y.^2))$

The result $\frac{x}{x^2+y^2}$