Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Topic: Help with RootLocusPlot
Replies: 0

 emammendes@gmail.com Posts: 143 Registered: 8/22/05
Help with RootLocusPlot
Posted: May 1, 2013 9:39 PM

Hello

I am using Manipulate to see how the gain k affects the response of a system. Two graphics are shown: OuputResponse and RootLocusPlot.

Below you will find the piece of code I am working with.

copenloop[k_,z_]:=TransferFunctionModel[(k(s+z))/(s(s+4)(s+6)),s];copenloop[k,z]

cclosedloop[k_,z_]:=SystemsModelFeedbackConnect[copenloop[k,z]];cclosedloop[k,z]

Clear[crlPlt,croots,crespPlt];

crlPlt[k_,z_]:=RootLocusPlot[Evaluate@copenloop[k,z],{k,0,250},PlotLabel->Style[Evaluate@copenloop[k,z] ,16],PlotRange-> Automatic,ImageSize-> {250,300},PlotStyle-> Thickness[0.02]];

croots[s_,loc_,z_]:=Quiet@Solve[copenloop[loc,z][[1,1,1,1]]/copenloop[loc,z][[1,2]]==-1,s];

crespPlt[tmax_,k_,z_]:=OutputResponse[cclosedloop[k,z],UnitStep[t],{t,0,tmax}];

Manipulate[GraphicsRow[{Show[Plot[Evaluate[crespPlt[100,loc,z]],{t,0,6},PlotRange->{All,{0,1.5}},AxesOrigin-> {0,0},GridLines->Automatic,GridLinesStyle-> Dashed,AspectRatio->Full,AxesLabel->{Style["t",Italic,14],Style["y(t)",Italic,14]},PlotLabel->Style["Step Response and Root Locus",16],PlotStyle-> Thickness[0.01],ImageSize-> {250,250}]],

Show[Evaluate@crlPlt[loc,z],Graphics[{Gray,AbsolutePointSize[10],Tooltip[Point[#],"k=="<>ToString[loc]]&/@({Re[s],Im[s]}/.croots[s,loc,z])}]]}],
Style["Root Locus" ,18,Bold],"",Delimiter,{{loc,k1,"Gain (k)"},0,100,1,Appearance->"Labeled"},Delimiter,{{z,z2,"Zero (z)"},0,20,1,Appearance->"Labeled"},SaveDefinitions-> True]

The second panel does not show what I need. What am I doing wrong? I feel that I am missing something ....

Many thanks

Ed