Question

It's my first time asking for help here, I hope someone respond. I was hoping to post images to show the problem I had but I need at least 10 reps to do it. But I hope everyone understand what I'm asking for.

I'm trying to create a manipulate box to plot a transfer function with type in boxes so that I can type in the the transfer function and specify the x and y axis. But the plot itself is not appearing only the axis are

but if i type the code outside of "manipulate" it works.

If you try running this on Mathematica you could probably see the problem I'm having.

My mathematica code is below.

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"]

Thank you.

Spiderfiq

Was it helpful?

Solution

Edit .. take 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}]

OTHER TIPS

This is some old code I had lying around from my System Dynamics and Controls class.

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top