Date: May 1, 2013 9:39 PM
Author: emammendes@gmail.com
Subject: Help with RootLocusPlot

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