Modeling Discrete Time Systems in Simulink: ECE 351 - Linear Systems II MATLAB Tutorial #5
Modeling Discrete Time Systems in Simulink: ECE 351 - Linear Systems II MATLAB Tutorial #5
MATLAB Tutorial #5
3. Click on the Create a New Model icon in the Library Browser window. An additional
window will open. This is where you will build your Simulink models.
4. Click on the + sign next to Simulink in the Library Browser. A list of sub-libraries will
appear including Continuous, Discrete, etc. These sub-libraries contain the most common
Simulink blocks.
5. Click once on the Sources sub-library. You should see a listing of blocks as shown in the
right column of figure 2.
>>
>>
>>
>>
clear
k=0:10;
x1=(1/2).^k;
x2=(-1/2).^k;
8. In order to transfer the sequence x1 into the Simulink model, double click on the simin block
and enter the values as shown in figure 3. The data field input is a matrix with the time or
sequence index (column 1) and values (column 2) vectors that were set up in the workspace.
Additionally, the time sampling rate that was used to generate these values is entered. Note
that the k and x1 vectors are converted to column vectors in the parameters window.
subplot(3,1,1)
stem(k,x1)
subplot(3,1,2)
stem(k,x2)
subplot(3,1,3)
stem(k,simout)
qk +1 = Aqk + Bxk
yk = Cqk + Dxk
where
A=[-1/2]
B = [1]
C=[-1/2]
D = [1]
Note that in this simple case A, B, C, and D are simple 1x1 elements, but in general they will be
matrices. Before performing the steps below, DO NOT clear the MATLAB workspace as you
will continue to need the inputs and output found in the previous section.
1. From the MATLAB command window, enter the following commands to input these four
matrices:
>>
>>
>>
>>
A=[-1/2];
B=[1];
C=[-1/2];
D=[1];
2. Open a new Simulink window and create the model shown below in figure 9. Note that the
Discrete State-Space block is found in the Discrete Library.
subplot(2,1,1)
stem(k,simout)
subplot(2,1,2)
stem(k,simout2)
Hopefully you will observe that both outputs are the same and hence the systems are
equivalent.