使用Mathematica Manipulate函数绘制传递函数

时间:2013-10-17 16:03:39

标签: plot wolfram-mathematica transfer

这是我第一次在这里寻求帮助,希望有人回复。我希望发布图像以显示我遇到的问题,但我需要至少10个代表才能做到这一点。但我希望每个人都能理解我的要求。

我正在尝试创建一个操纵框来绘制带有框中类型的传递函数,这样我就可以输入传递函数并指定x和y轴。但是情节本身并不仅仅出现在轴上

但如果我在“操纵”之外键入代码,它就可以工作。

如果您尝试在Mathematica上运行此功能,您可能会看到我遇到的问题。

我的mathematica代码如下。

Manipulate[tfplot,


 {{tfplot1, 0, "Transfer Function="}},


Delimiter,

 {{fmin1, 10, "fmin = "}},
 {{fmax1, 10^7, "fmax = "}},
 {{ymin1, 1, "ymin = "}},
 {{ymax1, 2*10^2, "ymax = "}},


 Delimiter,
 Row[{

   Button["Plot", tfplot = LogLogPlot[Abs[tfplot2[2*Pi*I*f] /. {tfplot2[s_] -> tfplot1}], {f, fmin1, fmax1}, PlotPoints -> 1000, PlotRange -> {{fmin1, fmax1}, {ymin1, ymax1}}, PlotLabel -> "tf Plot"], ImageSize -> 80] 
}]

 , ControlPlacement -> {Left, Left, Left, Left, Left, Left, Left, Top}]

tfplot3 = (3.333321894500285`*^6 (4.611679331492357`*^6 - 72057.48955456808` s - 4.138291871540356`*^9 s^3 - 3.889993968666704`*^9 s^4 + s^5))/(s^2 (2.606152799059127`*^18 + 4.6278171788297256`*^16 s + 1.0779994813998577`*^14 s^2 + 1.5235290577558628`*^8 s^3 + s^4))

LogLogPlot[Abs[tfplot4[2*Pi*I*f] /. {tfplot4[s_] -> tfplot3}], {f, 10, 10^7}, PlotPoints -> 1000, PlotRange -> {{10, 10^7}, {1, 2*10^2}}, PlotLabel -> "tf Plot"]

谢谢。

Spiderfiq

2 个答案:

答案 0 :(得分:0)

编辑..拿2 ..

Manipulate[
        fplot = LogLogPlot[Abs[tfplotf /. s -> 2*Pi*I*f], {f, fmin1, fmax1}, 
           PlotPoints -> 1000, PlotRange -> {{fmin1, fmax1}, {ymin1, ymax1}}, 
           PlotLabel -> "tf Plot"],
         {{tfplotf, (3.333321894500285`*^6 (4.611679331492357`*^6 - 
                72057.48955456808` s - 4.138291871540356`*^9 s^3 - 
                3.889993968666704`*^9 s^4 + 
                s^5))/(s^2 (2.606152799059127`*^18 + 
                4.6278171788297256`*^16 s + 1.0779994813998577`*^14 s^2 + 
                1.5235290577558628`*^8 s^3 + s^4))
           , "Transfer Function="}},
    Delimiter,
        {{fmin1, 10, "fmin = "}},
        {{fmax1, 10^7, "fmax = "}},
        {{ymin1, 1, "ymin = "}},
        {{ymax1, 2*10^2, "ymax = "}},
    Delimiter,
         ControlPlacement -> {Left, Left, Left, Left, Left, Left, Left, Top}]

答案 1 :(得分:0)

这是我在系统动力学和控制类中存在的一些旧代码。

Manipulate[tf = TransferFunctionModel[eq, s];

 BodePlot[tf, GridLines -> Automatic, ImageSize -> 500, 
  FrameLabel -> {{{"magnitude (db)", None}, {None, 
      "Bode plot"}}, {{"phase(deg)", None}, {"Frequency (rad/sec)", 
      None}}}, 
  ScalingFunctions -> {{"Log10", "dB"}, {"Log10", "Degree"}}, 
  PlotRange -> {{{0.1, 100}, Automatic}, {{0.1, 100}, 
     Automatic}}], {eq, (5 s)/(s^2 + 4 s + 25)}]

-Brian