[原创]信号与系统 Example 3.10 函数的Mathematica演示代码

 

Mathematica在做交互式的演示确实挺方便的,一行代码解决问题。不过里面的设置好复杂,得慢慢看。

在Signals and System by Alan V. Oppenheim, Alan S. Willsky这本书中的第214页 Example3.10中提到的函数$ x\left [ n \right ]=sin\left ( \omega _{0} n\right )  $,当$   \omega _{0} $取不同的值时,$  x\left [ n \right ] $可以是周期性的。当$   \omega _{0} $取不同的值时对应的函数图和$  x\left [ n \right ]  $是什么呢?如下,在网页https://www.wolframcloud.com/ (如果需要注册是可以免费注册的)中输入如下表达式,效果如截图。最后一个表达式通过调节$   \omega _{0} $的值可以画出不同情况下的曲线。

TraditionalForm[Sin[Subscript[\[Omega],0] *n]]

Plot[Sin[\[Pi] *0.5*n],{n,0,10},GridLines->Automatic]

 Manipulate[Plot[Sin[Subscript[\[Omega],0] *n],{n,0,10},GridLines->Automatic], {Subscript[\[Omega],0], 0, 2*\[Pi],\[Pi]/2}]

其中Subscript[\[Omega],0]是用来给$   \omega $显示下标的,\[Omega]是Mathematica中用来输入希腊字母的方法,

TraditionalForm[]是用来显示手写体的,Plot函数用来画图,Plot指令的第一个参数Sin[\[Pi] *0.5*n]是要画的函数的表达式,第二个参数{n,0,10}是自变量的范围,GridLines->Automatic用来设置网格线。

Manipulate[]可以实现交互式的界面,并可以指定其中的某个参数的变化范围,比如这里是 {Subscript[\[Omega],0], 0, 2*\[Pi],\[Pi]/2},指定$   \omega _{0} $的变化范围从0到$  2\pi  $,每次变化$   \frac{\pi}{2}  $。

 

如何使得网格更加密集呢?如何使得$   \omega _{0} $的值可以很好的显示出来呢(目前$   \omega _{0} $的值不能完整显示出来)?

 

 

Manipulate[
{p1=Plot[Sin[Subscript[\[Omega],0] *n],{n,0,10},GridLines->Automatic],
p2=ListPlot[Table[{m,Sin[Subscript[\[Omega],0] *m]},{m,0,10,1}],Filling->Axis,PlotStyle->{Red}]},{Subscript[\[Omega],0], 0, 2*\[Pi],\[Pi]/6}
]

 

 

 

Manipulate[
p1=Plot[Sin[Subscript[\[Omega],0] *n],{n,0,10},GridLines->Automatic];
p2=ListPlot[Table[{m,Sin[Subscript[\[Omega],0] *m]},{m,0,10,1}],Filling->Axis];
Show[{p1,p2}],{Subscript[\[Omega],0], 0, 2*\[Pi],\[Pi]/6}
]

 

 

 

 

Manipulate[
p1=Plot[Sin[Subscript[\[Omega],0] *n],{n,0,10},GridLines->Automatic];
p2=ListPlot[Table[{m,Sin[Subscript[\[Omega],0] *m]},{m,0,10,1}],Filling->Axis,PlotStyle->{Red}];
Show[{p1,p2}],{Subscript[\[Omega],0], 0, 2*\[Pi],\[Pi]/6}
]

 

 

 

 

 

 

 

 

 

 

 

 

 

 

ListPlot函数   https://reference.wolfram.com/language/ref/ListPlot.html.en?view=all

Table函数   https://reference.wolfram.com/language/ref/Table.html.en?q=Table&source=footer

 

posted on 2021-08-05 13:59  无声烟雨  阅读(309)  评论(0)    收藏  举报

导航