Mathematica函数的奇怪输出

时间:2011-10-25 21:38:25

标签: wolfram-mathematica

您好我无法理解以下功能的输出。

ListPointPlot3D[Table[Sin[x^2 + y],
                      {x, 0, 3, 0.15}, {y, 0, 3, 0.15}],
                      AxesLabel -> {"X axis", "Y axis", "Z axis"}
               ]

enter image description here

我告诉X和Y在区间[0,3]但是图表显示了来自大约[0,21]的这些变量的完全不同的范围。

这是怎么发生的?

4 个答案:

答案 0 :(得分:7)

您给了ListPointPlot3D一个值矩阵。每个值都被解释为" height" (z坐标)和值的矩阵索引作为x和y坐标。

也许你想要

ListPointPlot3D[Join @@ Table[{x, y, Sin[x^2 + y]}, {x, 0, 3, 0.15}, {y, 0, 3, 0.15}]]

Mathematica graphics

Plot3D[Sin[x^2 + y], {x, 0, 3}, {y, 0, 3}]

Mathematica graphics

另请查看Mesh的{​​{1}}选项的文档。

答案 1 :(得分:5)

您可以使用DataRange选项指定轴的范围:

ListPointPlot3D[Table[Sin[x^2 + y], {y, 0, 3, 0.15}, {x, 0, 3, 0.15}],
   AxesLabel -> {"X axis", "Y axis", "Z axis"}, 
   DataRange -> {{0, 3}, {0, 3}}]

Mathematica graphics

请注意,我还更改了x中的yTable迭代器,因为Table[..., {x, ..}, {y, ...}]对应Table[Table[..., {y, ...}], {x, ...}]。 (通过将0.15步长之一更改为1,您可以看到这是正确的。)

答案 2 :(得分:4)

所有2D List*绘图函数都使用List {{x1,y1},{x2,y2},...}作为第一个参数,这将正确绘制xy点。但是,如果您只提供一组坐标{y1,y2,...},那么它会使用每个y_i s的位置作为x刻度。同样适用于所有List*3D绘图功能。

因此,在您的情况下,只有一个变量z变量,它只使用Listx的各个子y的索引蜱。试试这个:

ListPointPlot3D[
 Flatten[Table[{x, y, Sin[x^2 + y]}, {x, 0, 3, 0.15}, {y, 0, 3, 
    0.15}], 1], AxesLabel -> {"X axis", "Y axis", "Z axis"}]

Mathematica graphics

答案 3 :(得分:1)

它似乎是每个'样本'而不是实际的x / y值,因为在0和3之间有20个0.15,这是你的表的步长