Sie sind auf Seite 1von 3

EE128Fall2009 MATLABCommands

UniversityofCalifornia,Berkeley Rev.1.0
UsefulMATLABCommands
YouwillbemainlyusingtheMATLABControlSystemToolbox.Agreatwaytogetstartedwith
thetoolboxistorunthedemo.Thisisdonebytypingdemo('toolbox','control')attheMATLAB
prompt.
PresentedherearethemostusefulMATLABcommandsforthisclass,groupedbytopic.For
furtherdetails,makegooduseofthehelpcommandinMATLAB.Ingeneral,otherthanthenecessary
MATLABlabtasks,MATLABshouldbeusedasatooltoverifyyourwork,notsubstituteforit.The
exception,ofcourse,isforcomputationallyintensiveproblems,inwhichcasemakesuretonoteonyour
assignmentthatyouusedMATLAB.
GeneralMatrices:
inv Inverseofamatrix.
conj Returnsthecomplexconjugateofanumber,vector,ormatrix.
transpose
(.)
Transposeofamatrix.transpose(A)isthesameasA..Youcandothecomplex
conjugatetransposeusingA.
eig Willreturnjusttheeigenvaluesofamatrixusingeig(A).Ifusedintheform
[v d] = eig(A),itwillalsoreturnasetofeigenvectors(notunique).
rank Returnstherankofamatrix.
TransferFunctions(TFs):
tf Entertransferfunctions.Theparametersarerowvectorsofthenumeratorand
denominatorcoefficients,respectively.
Ex:toentertheTFE(s) =
s+2
s
2
+5
,youcouldtypeH = tf([1,2],[1 0 5]).
conv Convolvetwopolynomials(representedasrowvectorsoftheircoefficients).Itis
particularlyusefulfordeterminingtheexpandedcoefficientsforfactoredpolynomials.
Ex:entertheTFE(s) =
s+2
(s+1)(s-3)
bytypingH = tf([1 2],conv([1 1],[1 -3])).
series(*) CombinetwoTFsthatareinseries.
Ex:ifE( and0( areinseries,getthecombinedTFI( withthecommandT = G*H
ORT = series(G,H).
s) s) s)
feedback CombinetwoTFsthatareinfeedback.
Ex:if0( isintheforwardpathandE( isinthefeedbackpath,gettheoverallTFI(
withthe ommandT = feedback(G,H).
s) s) s)
c
1
EE128Fall2009 MATLABCommands
UniversityofCalifornia,Berkeley Rev.1.0
step Plotthestepresponseofasystem.
Ex:step(T)plotsstepresponseofthesystemI( . s)
StabilityPlots:
rlocus Plottherootlocus.Keepinmindthatthiscommandisusedontheloopgainofthe
systemasopposedtotheclosedlooptransferfunction.Forexample,considerthestandard
negativefeedbacksystemwithforwardpath Gandfeedbackpath H .Theloopgainwould
be0( whereastheclosedloopTFwouldbe
1+u )
s) - E(s)
u(s)
(s)H(s
.
bode Plotsthefrequencyresponse.
Ex:bode(H)plotsthefrequencyresponse(bothmagnitudeandphase)forthesystemE( . s)
margin Calculatesgainandphasemarginsandcrossoverfrequencies.Ifusedwithoutreturnvalues,
plotsopenloopBodewithmarginsmarked.
Ex:[Gm,Pm,Wcg,Wcp] = margin(G)justreturnsvaluesforsystem0( while
margin(G)plotsthemvisually.
s)
nyquist NyquistfrequencyresponseofLTImodels.DoesNOTdisplaycontouratinfinity.Plotis
StateSpace:
ss CreatesstatespacemodelfromargumentmatricesA,B,C,andD.
Ex
oftenmisleadingbecauseofscale.Makesuretozoomandchangeaxesviewtogetthe
completepicture.
:ForpredefinedstatematricesA,B,C,andDoftheproperdimensions,use
tf2ss
ss2tf
Conversionbetweensystemrepresentations. returnsthe4matricesA,B,C,andD.
ctrb Computethecontrollabilitymatrixc = |
B
H =
ss(A,B,C,D).
tf2ss
ss2tfreturnsthepolynomials(incoefficientvectorform)forthenumeratorand
denominator.
AB A
n-1
B
].Onlyneedtopassitthe
obsv Computetheobservabilitymatrix0 = |
C CA CA
n-1
]
1
.Onlyneedtopassitthe
Plotting:
plot Plotsvectorsxvs.y.Youcanaddoptionssuchascolor,linetype,andmoreasathird
figure Selectswindow
matricesAandB.
matricesAandC.
argument.Seehelp plotformoreinfo.
toploton.
Ex:ToplotintothewindowtitledFigure1,usefigure(1)beforetheplotcommand.To
2
EE128Fall2009 MATLABCommands
UniversityofCalifornia,Berkeley Rev.1.0
3
subplot figure,butsplitsthecurrentfigureintosmallerregions.
openanewwindow,justusefigureanditwillopenanewwindowwiththeappropriate
number.
Similarto
Ex:Toplotxvs.y1andxvs.y2onthesameplotvertically(so2rowsand1column),use:
plotyy left,
axis appearance.Canbeusedtoreturncurrentaxesrangesormodify
title
l argumentandplacesitonthe
uenterstringsseparatedbycommasanditwillassignthemtothegraphs

RevisionHistory
subplot(2,1,1), plot(x,y1)followedbysubplot(2,1,2),plot(x,y2).
Plotstwolinesonthegraphwithseparateaxesforeach.Onewillbedisplayedonthe
theotherontheright.
Controlaxisscalingand
them.Therearealsoabunchofpresetmodes.Seehelp axisformoreinformation.
Placesacharactervectoronthetopofyourfigure.
xlabe
ylabel
Labelyouraxes.Thesetakeacharactervectorasan
appropriateaxis.
Addsalegend.Yo legend
intheordertheywereplotted.
SemesterandRevision Author(s) Comments
Winter2008
Rev.1.0
JustinHsia SeparatedtransferfunctionsectionfromLab1and
wroteallothergroups.

Das könnte Ihnen auch gefallen