Upload
nchubccl
View
35
Download
1
Embed Size (px)
Citation preview
Laboratory in Automatic Control
Lab 2
Simulation of System
Function (1/2)
• Syntax– w = conv(u,v)– r = roots(c)– p = poly(r)– v = polyval(p,x)
• Matlab code
3 2
( ) 1 1 1
( ) 3 3 1
( 5) 64
p s s s s
q s ss s
p
Example
p=conv([1 1],conv([1 1],[1 1]))r=roots(p)q=[1 3 3 1]roots(q)poly(r)polyval(p,-5)
Function (2/2)
Transfer function (1/11)
• Syntax– sys = tf(num,den)
• Matlab code
2
( )( )
( )
10
5
Y s numG s
U s den
s
Method 1num=[10];den=[1 0 5];G1=tf(num,den);
Method 2G2=tf([10],[1 0 5]);
Example
U(s) Y(s)System
Transfer function (2/11)
( 1)( 2)( )
( 2 )( 2 )( 3)
s sH s
s i s i s
n1=[1 1];n2=[1 2];d1=[1 2*i];d2=[1 -2*i];d3=[1 3];% d1=[1 2*j];d2=[1 -2*j];d3=[1 3];num=conv(n1,n2);den=conv(d1,conv(d2,d3));H=tf(num,den)
Example
Transfer function (3/11)
• Syntax– step(sys)– step(sys,t)
– step(sys1,sys2,...,sysN)– step(sys1,sys2,...,sysN,
t)– step(sys1,'PlotStyle1',...,
sysN,'PlotStyleN')
( ) 10( )
( ) 5
Y s kG s
U s s
Example
U(s) Y(s)System
U(s): unit step signal
K=1,2,5
Transfer function (4/11)
• Matlab code
k=1;G1=tf(10*k,[1 5])k=2;G2=tf(10*k,[1 5])k=5;G3=tf(10*k,[1 5])step(G1,'-',G2,'*',G3,'o')
Transfer function (5/11)
• Matlab code
k=1;G1=tf(10*k,[1 5])k=2;G2=tf(10*k,[1 5])k=5;G3=tf(10*k,[1 5])step(G1,'-',G2,'*',G3,'o',5)
Transfer function (6/11)
• Syntax– p = pole(sys)– z = zero(sys)
– pzmap(sys)– pzmap(sys1,sys2,...,sysN)
Transfer function (7/11)
2
1( )
3 2
sG s
ss
• Matlab code
G=tf([1 1],[1 3 2])pole(G)zero(G)pzmap(G)
Example
Transfer function (8/11)
Transfer function (9/11)
• Syntax– [z,p,k] = tf2zp(num,den)– [num,den] = zp2tf(z,p,k)
• Matlab code
Example
% Transfer function convert to pole-zero[z,p,k] = tf2zp([1 1],[1 3 2])% Pole-zero convert to transfer function[num, den] = zp2tf(z,p,k)transfer_function=tf(num, den)
Transfer function (10/11)
• Syntax– sysr = minreal(sys)– Minimal realization and pole-zero cancellation
• Matlab code
G=tf([1 6 5],[1 3 2])minreal(G)pole(G)zero(G)
Transfer function (11/11)
Series and parallel connection
• Syntax– sys = series(sys1,sys2)
– sys = parallel(sys1,sys2)
The feedback function (1/5)
• Syntax : initial sign=-1– sys = feedback(sys1,sys2)– sys =
feedback(sys1,sys2,sign)
– Note: sign=
If sign=-1 then system was negative feedback.
If sign=+1 then system was positive feedback.
1Sys1
Sys2
sign
+
The feedback function (2/5)
• Matlab codeExample
n1=[2 5 1];n2=[1 2];d1=[1 2 3 ];d2=[1 10];G=tf(n1,d1);H=tf(5*n2,d2);F1=feedback(G,H)F2=feedback(G,H,-1)F3=feedback(G,H,1)
相等2
2
5 12( )2 3
5( 2)( )
10
ssG sss
sH s
s
The feedback function (3/5)
Result:
Showing F1, F2, and F3, respectively
The feedback function (4/5)
• Unity feedback• Matlab code Example
n1=[2 5 1];n2=[1 2 3];G=tf(n1,n2);f1=feedback(G,1)f2=feedback(1,G)
2
2
5 12( )2 3
ssG sss
The feedback function (5/5)
Result:
Showing f1 and f2, respectively
Lab Assignments
• Solve Problems P1 and P2
• Lab report should at least contain:– The MATLAB code and the plot for P1– The plot generated for P2 (Please plot all 3
curves on the same plot)
Lab HomeworkP1.
Consider the feedback system depicted in the figure.
(a) Compute the closed-loop transfer function using the series and feedback functions.
(b) Obtain the closed-loop system unit step response with the step function, and verify that final value of
the output is 2/5.
1
1s
Controller
2
3
s
s
Plant
R s Y s
Lab Homework
2
P2.
A system has a transfer function
15 /
3 15
Plot the response of the system when is a unit
step for the parameter 3,6, and 12.
X s z s z
R s s s
R s
z