Vous êtes sur la page 1sur 23

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)

Example
p( s) s 1 s 1 s 1 q( s) s 3 3s 2 3s 1 p(5) 64

Matlab code
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)

Example
U(s)
System

Matlab code
Method 1 num=[10];den=[1 0 5]; G1=tf(num,den); Method 2 G2=tf([10],[1 0 5]);

Y(s)

Y ( s ) num G(s) U ( s ) den 10 2 s 5

Transfer function (2/11)


Example
( s 1)( s 2) H ( s) ( s 2i )( s 2i )( s 3)

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)

Transfer function (3/11)


Syntax
step(sys) step(sys,t)

Example
U(s)
System

Y(s)

step(sys1,sys2,...,sysN) step(sys1,sys2,...,sysN,t) step(sys1,'PlotStyle1',..., sysN,'PlotStyleN')

Y ( s ) 10k G (s) U (s) s 5


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)


Example
s 1 G( s) 2 s 3s 2

Matlab code
G=tf([1 1],[1 3 2]) pole(G) zero(G) pzmap(G)

Transfer function (8/11)

Transfer function (9/11)


Syntax
[z,p,k] = tf2zp(num,den) [num,den] = zp2tf(z,p,k)

Example

Matlab code
% 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= 1 If sign=-1 then system was negative feedback. If sign=+1 then system was positive feedback.

+ Sys1 sign Sys2

The feedback function (2/5)


Example
Matlab code
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 s 5s 1 G (s) 2 s 2s 3 5( s 2) H ( s) s 10
2

The feedback function (3/5)


Result: Showing F1, F2, and F3, respectively

The feedback function (4/5)


Unity feedback Matlab code
n1=[2 5 1];n2=[1 2 3]; G=tf(n1,n2); f1=feedback(G,1) f2=feedback(1,G)
2 2 s 5s 1 G (s) 2 s 2s 3

Example

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 Homework
P1. 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.

Controller
R s

Plant
s2 s3

1 s 1

Y s

Lab Homework
P2. A system has a transfer function X s R s

15 / z s z
s 2 3s 15

Plot the response of the system when R s is a unit step for the parameter z 3, 6, and 12.

Vous aimerez peut-être aussi