Mathematica常用命令记录

1.复数函数(带参数)画图

point = Table[1/(3 + 4 I)*E^(3 t)*E^(4 t I), {t, 0, 2, 0.01}];
ListPlot[ReIm[point], PlotRange -> All]

2.复数化简

先Simplify[ComplexExpand[...]],由此实部得到,但虚部可能还不是最简,再RootReduce[Im[%]]。

3.使得坐标轴大小真实并固定轴长度

ListPlot[data, AspectRatio -> Automatic, Frame -> True,PlotRange -> {{xmin, xmax}, {ymin, ymax}}]

例子:

Manipulate[
  ListPlot[
    Table[{Cosh[c]*Cos[x], Sinh[c]*Sin[x]}, {x, -10, 10, 0.05}],
    AspectRatio -> Automatic, 
    Frame -> True,
    PlotRange -> {{-100, 100}, {-100, 100}}
  ], 
  {c, 0, 10}
]

4.Animate正确用法

当表达式仅含时变变量时,在有些必须要求有变量的函数中,只能笨批添加0变量使得语法正确,才能正常运行。例如本例中的x变量,一直是0.

Animate[
    ListPolarPlot[
        Table[{2*ArcTan[x + t] + Pi, 1}, {x, 0, 0}], 
        AspectRatio -> Automatic, Frame -> True, PlotRange -> {{-2, 2}, {-2, 2}}
        ],
 {t, 0, 10, 0.01}
]

5.Table维数处理

得益于笨批的Table系统,常常无法得到想要的维度的数据。常常配合Flatten和Partition使用。本例是一个卡西尼曲线的模曲面绘制。

ListPlot3D[
  Partition[
    Flatten[
      Table[
      {a, b, Norm[(a + I b + 1) (a + I b - 1) (a + I b + 1 + I)]}, 
      {a, -10, 10, 0.1}, 
      {b, -10, 10, 0.1}
      ]
    ], 
  3],
 AspectRatio -> Automatic, 
 PlotRange -> {{-10, 10}, {-10, 10}, {-10, 10}}
 ]

6.For循环

For[
i = 1, i <= 6, i++, 
 point = Table[{x, F(x), {x, -4*Pi, 4*Pi, 0.1}]
]
; ListPlot[point]

7.级数画图并动画

Animate[
  point = Table[ 
    {x, Sum[(-1)^(i + 1)*Sin[i x]/i, {i, 0 + a}]},
    {x, -4*Pi, 4*Pi, 0.1}
  ]; ListPlot[point], 
{a, 1, 10}]

这里可以看出,即使是(赋值句+画图句)的组合,也被视作一个expr

发布了43 篇原创文章 · 获赞 11 · 访问量 3万+

猜你喜欢

转载自blog.csdn.net/qq_41524721/article/details/90345106