Search code examples
plotwolfram-mathematicatransfer

Using Mathematica Manipulate function to plot a transfer function


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


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