Download Lab 3 - UniMAP Portal

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts

Signal-flow graph wikipedia , lookup

Equation wikipedia , lookup

System of linear equations wikipedia , lookup

System of polynomial equations wikipedia , lookup

Transcript
Lab Manual EKT230/4
Signals & Systems
LABORATORY 3
DIFFERENCE EQUATIONS & STATE-VARIABLES
1.0
OBJECTIVES:
After completing this lab you will be able :
1.1
To manipulate State Variables Description and Difference Equations.
1.2
Use “filter” command, “filtic” command and “impz” command
correctly.
2.0
TOOLS
The MATLAB Signal Processing Toolbox.
3.1
SIMULATING DIFFERENCE EQUATIONS
Differential Equation (DE)
y ( n ) (t )  a n 1 y ( n 1) (t )  .....  a1 y (t )  a0 y (t )  bm x ( m ) (t )  bm 1 x ( m 1) (t )  .....  b0 x(t )1
.
y ( n 1) (0)  y n 1 , y ( n  2) (0)  y n  2 ,....... y (0)  y1 , y (0)  y 0
Coefficients ak and bk are real numbers; m ≤ n. DE are widely used to model
physical processes. They occur frequently in networks, dynamics, physics, etc.
To express the Difference Equation description of a system in recursive form that
allowed the system output to be computed for the input signal & past output, we
use the “filter” command.
N
 a k y[n  k ] =
K 0
Define vectors
M
 b x[n  k ]
K 0
k
den = [ a0, a1, ……, aN ]
num = [ b0, b1, ……, bM ]
if X is a vector representing the input signal.
then , vector y = filter ( num, den, x ) …..
representing the output of the
system at zero, initial condition.
For
non-zero
initial
conditions,
we
use
alternative
command
syntax, y = filter ( num, den, x, Zi ), where Zi represent the initial condition
24
Lab Manual EKT230/4
Signals & Systems
required by filter. The command “[h, t] = impz(num, den, n)” evaluates “n”
values of the impulse response of a system described by a difference equation.
The vector h contains the values of the impulse response, and t contains the
corresponding time indices.
Note: The initial conditions used by “filter” are not the past values of the output.
These initial conditions are obtain from knowledge of the past outputs, using
command
Zi = filtic ( num, den, yi ) ,
where yi is a vector containing, initial condition in the order [ y [-1], y[-2], …..,
y [-N]].
Example 3.1.1
A system is described by the Difference Equation,
y [n] – 1.143y [n-1] + 0.4128y [n-2] = 0.0675x[n] + 0.1349x[n-1] + 0.675x[n-2]
Determine the output in response to zero input and initial condition,
y[-1] = 1 and y[-2] = 2, [first 50 values]
Solution 3.1.1
>> clear
>> n = [1:50];
@
[0:49]
>> den = [1, -1.143, 0.4128];
>> num = [0.0675, 0.1349, 0.675];
>> x = zeros (1, 50);
>> Zi = filtic ( num, den, [1, 2] );
% initial condition y[-1] = 1 & y[-2] = 2
>> y = filter ( num, den, x, Zi);
>> stem (n,y)
25
Lab Manual EKT230/4
3.2
Signals & Systems
STATE – VARIABLE DESCRIPTIONS
Systems are manipulated in MATLAB by operation on their LTI objects. By using
the MATLAB Control System Toolbox, we are enabling to manipulate LTI
System descriptions as Single MATLAB variables.
The command “SyS = ss (a,b,c,d,-1)” produces an LTI object “SyS” that
represents the discrete-time system in state-variable form. While for a
continuous-time system, omits the ‘-1’ that is, by using ,
“SyS = ss (a,b,c,d)
_______________ Continuous-time System
if SyS1 and SyS2 are objects representing two systems in state variable form,
then
SyS = SyS1 + SyS2 _________________
parallel combination
SyS = SyS1 * SyS2 _________________
cascade combination
The function “LSIM” Simulates the output of an LTI system in response to a
specified input.
y = Lsim ( SyS, x ) _____________
x = vector input
h = impulse ( SyS, N ) ______ N = value of the impulse response in ‘h’.
Different state-variable descriptions for the LTI system are obtained by
transforming the state. The State transformation is identical for both continuous
& discrete-time system. The command is of the form
SyST = ss2ss (SyS, T)
Where, SyST = Transformed state-variable description
SyS = the original state variable description
T = the state transformation matrix.
26
Lab Manual EKT230/4
Signals & Systems
Example 3.2.1
A discrete-time system has the state variable description
A = 1/10
-1
4
4
,
B=
2
-1
C = 1/2
1
4
1
, D=2
Using the state-transformation matrix
T = 1/2
-1
1
1
1
Using MATLAB, find the state-variables description A’, B’, C’, D’.
The following commands produce the designed result:
>> a = [-0.1, 0.4; 0.4, -0.1] ;
>> c = [0.5, 0.5] ;
b=[2;4];
d=2;
>> SyS = ss (a, b, c, d,-1)
% define the state-space object system
>> T = 0.5 * [-1, 1; 1, 1];
>> SyST = ss2ss ( SyS,T)
a=
x1
x2
x1
-0.50000
0
x2
0
b=
0.30000
u1
x1
1.0000
x2
3.0000
c=
x1
y1
d=
0
x2
1.00000
u1
y1
2.00000
27
Lab Manual EKT230/4
Signals & Systems
To verify that the two systems represented by SyS and SyST have identical
input-output characteristic by comparing their impulse by responses via the
following commands.
>> h = impulse (SyS, 10);
>> hT = impulse ( SyST,10);
>> subplot ( 2,1,1 );
>> stem ( [0:9],h );
>> title (‘Original System Impulse Response’);
>> xlabel (‘Time’); ylabel (‘Amplitude’);
>> subplot (2,1,2);
>> stem ( [0:9], hT);
>> title (‘Transformed System Impulse Response’);
>> xlabel (‘Time’); ylabel (‘Amplitude’);
Problem 3.2.1
A continuous-time system has the state variable description
A=
C=[0
-2
0
1
-1
2]
,
B=
1
1
D=1
Using MATLAB, find the state-variables description A’, B’, C’, D’.
Corresponding to the new states,
q1’ (t) = 2q1 (t) + q2 (t) and q2’ (t) = q1 (t) – q2 (t)
28
Lab Manual EKT230/4
Signals & Systems
TASKS OF THE DAY
Q 3.1 Use the MATLAB commands filter and filtic to determine the first 50 output
values in the following problems. The output of the systems is described by the
following difference equations with input and initial condition as specified.
(a) y[n] - 1/2 y[n-1] = 2 x[n]
y[-1] = 3,
x [n] = (- ½ )n u[n]
(b) y[n] - 3/4 y[n-1] + 1/8y[n-2] = 2x[n]
y[-1] = 1, y[-2] = -1, x[n] = 2 u[n]
Q 3.2 Use the MATLAB command ss2ss to solve following problems. Let a discretetime system have the state variables description given by
A=
1
1/3
C= [1
- 1/2
;
B=
-1
-1]
1
2
;
and
D=[0]
(a) Define new state q1’ [n] = 2q1 [n], q2’ [n] = 3 q2 [n]
Find the new state variable description given by
A’, B’, C’ and D’.
(b) Define new state q1’ [n] = 3q2 [n], q2’ [n] = 2q1 [n]
Find the new state variable description given by
A’, B’, C’ and D’.
(c) Define new state q1’ [n] = q1 [n] + q2 [n] , q2’ [n] = q1 [n] - q2 [n]
Find the new state variable description given by
A’, B’, C’ and D’.
29
Lab Manual EKT230/4
Signals & Systems
Q 3.3 (a) Use the MATLAB commands lsim and impulse to determine the first 30
values of the step and impulse response of this system.
(b) Defines new state q1 [n] = q1 [n] + q2 [n] and q2 [n] = 2q1 [n] - q2 [n] .
Repeat Part (a) for the transformed system. A system has the state-variable
description.
A=
1/2
1/3
C= [ 1
- 1/2
,
0
-1 ]
B=
1
2
,
D= [0]
30