ME 4710 Motion and Control Some Useful MATLAB Commands

advertisement
ME 4710 Motion and Control
Some Useful MATLAB Commands
Defining a Sequence of Values
time = [0:0.01:10];.................defines the sequence of values [0, 0.01, 0.02, ..., 10]
Note that any words inside of quotation marks are just names. They could very well be “num1” or
“denominator.” All words bolded are inputs into MATLAB. Also, the semi-colon following any
command will cause the result to not be displayed.
Defining a Polynomial
num=[1,2];………………….yields “num” = (s+2)
den=[3,4,7];…………………yields “den” = (3s2+4s+7)
Defining a Transfer Function
sys=tf(num,den)
“sys” is the desired name of a system. It could very well be “sys2” or “system.”
“tf” is the MATLAB command that defines the transfer function of “sys” as num den
clsys=feedback(sys1,sys2, ± 1)
Calculates the transfer function of a closed loop system. “sys1” is the transfer function in the
forward path, and “sys2” is the transfer function in the feedback path. The value ±1 determines
whether the feedback is positive or negative.
Convolution – Products of Polynomials
conv([1,2],[3,4]);...........................yields the product of (s+2)(3s+4). This command can be useful
when dealing with complex numerators or denominators.
conv([1,0],conv([1,2],[3,4]));……yields the product of s(s+2)(3s+4).
Root Locus Diagram
figure(1); rlocus(sys)………plots the root locus diagram for “sys” in figure window 1
grid………………………….creates a grid on the root locus plot
[k,poles]=rlocfind(sys)……..allows selection of points on root locus of “sys” and gives k-values and
pole locations
sgrid(0.6,0)………………….gives gridlines at a damping ratio of ζ = 0.6
axis(‘equal’)………………...produces axes with equal scaling
Bode Diagrams
figure(1); bode(sys)………...plots the bode diagram for “sys” in figure window 1
grid………………………….creates a grid on the bode plot
margin(sys)…………………shows phase and gain margins for “sys”
Step Response
figure(2); step(sys)…………plots the step response of “sys” in figure window 2
step(sys,time).........................plots the step response of “sys” on the time vector “time”
grid………………………….creates a grid on step response
Download