0
|
7200 Views
|
3 Replies
|
0 Total Likes
View groups...
Share
GROUPS:

# Plot a two variable function but with another variable in the x-axis

Posted 9 years ago
 Hello everybody, I need help. I want to plot a function "f" which depends on two variable, "x" and "y", but I want "sqrt(x^2+y^2)" in the abscissa axis, not x or y. So, I want a plot in 2D: sqrt(x^2+y^2) in the abscissa axis and f[x,y] in the ordinate axis. How can I do it? My "x" and "y" variable are defined on the interval {x, 0, xmin} and {y, 0, ymax} respectivly. (My idea is like if my function depends on a vector (x,y) and I want to make a plot with the modulus of the vector in the abscissa axis)
3 Replies
Sort By:
Posted 9 years ago
 pts = Table[ i * {xmax, ymax}, {i, 0, 1, .01}]
Posted 9 years ago
 Thank you!But I think I forgot something important when explaining my problem. The point is that I don't want that each value of x is with all the possible values of y. What I want is that for each value of x there is only a possible value of y, even if they are not the same values. For example, now, with your code, I have this table:{0, 250000000}, {0, 300000000}, {0, 350000000}, {0, 400000000},... (all the possible combinations of the point x1=0 with all the y points) {3150000000, 0}, {3150000000, 50000000}, {3150000000, 100000000},... (all the possible combinations of the point x2=3150000000 with all the y points)And what i want is something like this:{0, 0}, {250000000, 300000000}, {35000000, 350000000},...Is there a way to get only the points (x1, y1), (x2, y2), ..., (xmax, ymax)?That's what I have now: Table[{x, y}, {x, 0, 3154209492, 50000000}, {y, 0, 5463251097, 50000000}] hbar := UnitConvert[1 \[HBar], "Electronvolts" "Seconds"]; mass := ParticleData["Electron", "Mass"]; f[x_, y_] = (hbar^2)*(x^2 + y^2)/(2 mass) ; mod[{x_, y_}] = Sqrt[x^2 + y^2]; pts = Flatten[ Table[{x, y}, {x, 0, 3154209492, 50000000}, {y, 0, 5463251097, 50000000}]]; fpts = f /@ pts; modpts = mod /@ pts; ListPlot[Transpose[{modpts, fpts}]] 
Posted 9 years ago
 I think ListPlot is the way to go, since you'll probably have multiple values of f[ x, y] for the same value of sqrt(x^2 + y^2 ). f[{x_, y_}] = Sin[x y]; mod[{x_, y_}] = Sqrt[x^2 + y^2]; pts = Flatten[Table[{x, y}, {x, 0, 10, .1}, {y, 0, 10, .1}], 1]; fpts = f /@ pts; modpts = mod /@ pts; ListPlot[Transpose[{modpts, fpts}]]