文章目录(Table of Contents)
问题
原文
I'm making plots of point sets in a plane. My points are generated by a function ranging over two parameters xx and yy and I want to see all the points where these are integers between −10−10 and 1010. But the function is undefined when x=y=0x=y=0.
Following is a version of my code where I've replaced the function with something simpler, that is also undefined at x=y=0x=y=0.
ListPlot[Table[{x/(x^2+y^2),y/(x^2+y^2)},{x,-10,10,1},{y,-10,10,1}]]
If you implement that code, you will get the graph but with error messages about the point where it's undefined. (In reality what I'm doing is more complicated and involves a slidable parameter, which compounds the problem because every time you slide the parameter Mathematica hits the undefined point again.)
What is the easiest way to omit the combination x=y=0x=y=0 from the combination of data ranges?
翻译
我正在想在平面上画一些点。我的点是有一个函数产生的,这个函数有两个参数x和y,我想看到所有这些x和y是整数并且在-10到10之间的点,但是函数在x=y=0的时候没有定义。
下面是我的代码,我把其中的函数换成了较简单的,但是他同样在x=y=0的地方没有被定义。
ListPlot[Table[{x/(x^2+y^2),y/(x^2+y^2)},{x,-10,10,1},{y,-10,10,1}]]
如果你执行这段代码,你将会得到图但是同时在那些没有被定义的点处会有报错。(在实际情况下,我做的会更加复杂,并且包含一个滑动的参数使得问题变得更加复杂,这样就会导致每次我滑动参数Mathematica都会遇到没有被定义的点)
想问一下最简单的方式从原有数据中忽略x=y=0的这些组合的方法是什么?
高票回答
原文
another option is to implement your own region function like for listplot:
(*constraint here*)
f[x_, y_] /; (x^2 + y^2 != 0) := {x/(x^2 + y^2), y/(x^2 + y^2)}
f[x_, y_] := Nothing; (*what to return for bad region, or other point*)
ListPlot[Table[f[x, y], {x, -10, 10, 1}, {y, -10, 10, 1}]]
翻译
另一个选择在ListPlot的时候执行你的区域的函数(使用分段函数)
(*在这里加以限制*)
f[x_, y_] /; (x^2 + y^2 != 0) := {x/(x^2 + y^2), y/(x^2 + y^2)}
f[x_, y_] := Nothing; (*对没有定义的地方返回Nothing*)
ListPlot[Table[f[x, y], {x, -10, 10, 1}, {y, -10, 10, 1}]]
![omit a pairing of numbers from two data ranges in a table(从table产生的两组数中忽略一些数据范围)–[2]](https://img.mathpretty.com/snipaste_20170923_155445.png?imageView2/0/q/75|watermark/2/text/5YWz5rOo5YWs5LyX5Y-377ya5paH6Im65pWw5a2m5ZCb/font/5b6u6L2v6ZuF6buR/fontsize/540/fill/IzAwMDAwMA==/dissolve/100/gravity/SouthEast/dx/10/dy/10|imageslim)
生词&&一些好的翻译
- omit:忽略
- plane:平面
- implement:执行
- parameter:参数
- constraint:约束
- customize:定制
祝好
- 微信公众号
- 关注微信公众号
-
- QQ群
- 我们的QQ群号
-

![Creating a third list from two given lists(通过以给出的两个列表创建第三个列表)--[5]](https://img.mathpretty.com/20210911_162105_q285v1d.jpg)
![Add 1 to diagonal elements of a matrix(矩阵的对角元素加1)--[4]](https://img.mathpretty.com/20210911_162044_qrizd11.jpg)
![在使用Grid中的Frame->All时,如何不要在空白的单元格加边框--[3]](https://img.mathpretty.com/20210911_161401_9q0dovo.jpg)
![Geolocate multiple IP addresses(获取大量IP地址的地理位置)--[1]](https://img.mathpretty.com/20210911_162108_oqvo4xz.jpg)

评论