0% found this document useful (0 votes)
16 views11 pages

EEE 4606 Lab 01

The document outlines a Control System Engineering Lab experiment focused on MATLAB/Simulink implementation for modeling and analyzing the response of Linear Time-Invariant (LTI) systems. It includes objectives, detailed procedures for modeling an RL circuit, and instructions for using MATLAB and Simulink to derive and visualize system responses. Additionally, it provides examples of transfer function representations and system response analyses, along with assignments for further exploration of circuit behaviors.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views11 pages

EEE 4606 Lab 01

The document outlines a Control System Engineering Lab experiment focused on MATLAB/Simulink implementation for modeling and analyzing the response of Linear Time-Invariant (LTI) systems. It includes objectives, detailed procedures for modeling an RL circuit, and instructions for using MATLAB and Simulink to derive and visualize system responses. Additionally, it provides examples of transfer function representations and system response analyses, along with assignments for further exploration of circuit behaviors.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 11

Control System Engineering Lab 1

ISLAMIC UNIVERSITY OF TECHNOLOGY (IUT)


ELECTRICAL AND ELECTRONIC ENGINEERING (EEE)
CONTROL SYSTEM ENGINEERING LAB

Experiment Name
MATLAB/Simulink Implementation for Modelling and Response Analysis of LTI Systems

1 Objectives
• To develop analytical and simulation models of systems using MATLAB and Simulink,
and compare their step responses through both mathematical derivation and computa-
tional techniques.
• To understand and implement transfer function representations of LTI systems through
various MATLAB commands, and to analyze their pole-zero configurations.
• To investigate system responses (step, impulse, ramp) for different types of feedback
control systems.

2 PART A: Modelling using MATLAB and Simulink


2.1 MATLAB Code

Figure 1: Series RL circuit

The RL circuit under consideration is shown in Figure 4.7, consisting of a voltage source Vin (t),
a resistor R, and an inductor L, with the current i(t) as the output.

Derivation of the Differential Equation


Applying Kirchhoff’s Voltage Law (KVL) around the loop:

Vin (t) = VR (t) + VL (t)

Mohammad Abrar Kabir, IUT, EEE


Control System Engineering Lab 2

where VR (t) = Ri(t) and VL (t) = L di(t)


dt
. Substituting these into the equation:

di(t)
Vin (t) = Ri(t) + L
dt
Rearranging, the first-order differential equation is:
di(t)
L + Ri(t) = Vin (t)
dt

Laplace Transform and Transfer Function


Assume zero initial conditions (i(0) = 0). Taking the Laplace transform of the differential
equation:
LsI(s) + RI(s) = Vin (s)
Factoring out I(s):
I(s)(Ls + R) = Vin (s)
I(s)
The transfer function H(s) = Vin (s)
is:

I(s) 1
H(s) = =
Vin (s) Ls + R

The following MATLAB code defines the transfer function for the RL circuit with L = 1 H
and R = 2 Ω, and plots its step response:
1 L = 1;
2 R = 2;
3 num = 1;
4 den = [ L R ];
5 h = tf ( num , den ) ;
6 step ( h ) ;

Analytical Solution for Step Input


Consider a step input Vin (t) = V0 u(t), where V0 = 1 V and u(t) is the unit step function.
Substituting into the differential equation:
di(t)
L + Ri(t) = 1 for t ≥ 0
dt
Divide through by L:
di(t) R 1
+ i(t) =
dt L L
The homogeneous solution is found by solving:
dih (t) R R
+ ih (t) = 0 =⇒ ih (t) = Ae− L t
dt L
The particular solution for a constant input is:
1
ip (t) =
R

Mohammad Abrar Kabir, IUT, EEE


Control System Engineering Lab 3

This is determined using the method of undetermined coefficients. Since the forcing term is
a constant ( L1 ), we assume a constant particular solution ip (t) = K. Substituting into the
differential equation:
d R 1
(K) + K =
dt L L
Since K is a constant, its derivative is zero:
R 1 R 1 1
0+ K= =⇒ K= =⇒ K =
L L L L R

The total solution is the sum of the homogeneous and particular solutions:
R 1
i(t) = ih (t) + ip (t) = Ae− L t +
R
Using the initial condition i(0) = 0 (assuming the inductor current starts at zero):
1 1 1
i(0) = Ae0 + = A + = 0 =⇒ A = −
R R R

Thus, the final analytical solution for the current i(t) is:
1 R 1 1 R

i(t) = − e− L t + = 1 − e− L t for t ≥ 0
R R R

The following MATLAB code plots both the simulated step response and the analytical solution
of the RL circuit for L = 1 H and R = 2 Ω, using subplots for comparison:
1 L = 1;
2 R = 2;
3 num = 1;
4 den = [ L R ];
5 h = tf ( num , den ) ;
6 [y , time ] = step ( h ) ;
7

8 % Analytical solution function


9 math_function = @ ( t ) (1/ R ) *(1 - exp ( - R * t / L ) ) ;
10 math_solution = math_function ( time ) ;
11

12 % Create subplots for comparison


13 subplot (2 ,1 ,1) ;
14 plot ( time , y , ’b - ’ , ’ LineWidth ’ , 1.5) ;
15 grid on ;
16 title ( ’ Simulated Step Response ( MATLAB ) ’) ;
17 xlabel ( ’ Time ( s ) ’) ;
18 ylabel ( ’ Current i ( t ) ( A ) ’) ;
19 set ( gca , ’ FontSize ’ , 10 , ’ GridColor ’ , ’k ’ , ’ GridAlpha ’ , 0.3) ;
20

21 subplot (2 ,1 ,2) ;
22 plot ( time , math_solution , ’r - - ’ , ’ LineWidth ’ , 1.5) ;
23 grid on ;
24 title ( ’ Analytical Step Response ’) ;

Mohammad Abrar Kabir, IUT, EEE


Control System Engineering Lab 4

25 xlabel ( ’ Time ( s ) ’) ;
26 ylabel ( ’ Current i ( t ) ( A ) ’) ;
27 set ( gca , ’ FontSize ’ , 10 , ’ GridColor ’ , ’k ’ , ’ GridAlpha ’ , 0.3) ;
28

29 % Adjust layout for better spacing


30 set ( gcf , ’ Color ’ , ’w ’) ;
31 sgtitle ( ’ Comparison of RL Circuit Step Response ( R =2\ Omega , L =1 H ) ’ ,
’ FontSize ’ , 12) ;

2.2 Simulink
2.2.1 S Domain
1
The Simulink model for the RL circuit uses the transfer function H(s) = Ls+R
, with R = 2 Ω
and L = 1 H, so:
1
H(s) =
s+2
The model includes:

• Step Block: Step input.


1
• LTI System Block: Transfer function s+2
.
• Scope Blocks: Scope and Scope1 for output visualization.
• To Workspace Block (simout): Exports data in array or structure format.

Block diagram: Step → LTI System → Scope/Scope1 → To Workspace (simout).


Data export and plotting:

Mohammad Abrar Kabir, IUT, EEE


Control System Engineering Lab 5

1 t = out . simout . Time ; % Extract time from timeseries


2 y = out . simout . Data ; % Extract data from timeseries
3

4 plot (t , y ) ;
5 xlabel ( ’ Time ( s ) ’) ;
6 ylabel ( ’ Current i ( t ) ( A ) ’) ;
7 title ( ’ RL Circuit Step Response ( Structure Format ) ’) ;
8 grid on ;

2.2.2 Time Domain


The time-domain Simulink model for the RL circuit uses the governing equation:

di(t) di(t) 1
L + Ri(t) = Vin (t) or = (Vin (t) − Ri(t))
dt dt L
Steps to build the model:

1. Compute Vin (t) − Ri(t):

Block diagram: Step (Vinput) → Subtract (Vinput - R*i) ← i(t)

1
2. Multiply by L
using a Gain block:

Subtract → Gain (K = 1/L) → Output

di(t)
3. The output of the Gain is dt
. Integrate to get i(t):

Gain → Integrator (1/s) → i(t)

4. Connect the integrator output back to the subtract block:

Integrator → Subtract

5. Add a Scope to observe i(t):


Integrator → Scope
1
For R = 2 Ω, L = 1 H, set Gain K = L
= 1, and multiply i(t) by R = 2 in the feedback path
if needed.

Mohammad Abrar Kabir, IUT, EEE


Control System Engineering Lab 6

3 PART B: Representation of Linear Time-Invariant Systems using


Matlab
3.1 Representing Transfer Functions
Example 1: Basic Transfer Function Representation
For the transfer function:
s
G(s) =
s2+s+4
Use the tf function, including coefficients for all powers of s, even if zero:
1 num = [1 , 0];
2 den = [1 , 1 , 4];
3 G = tf ( num , den ) ;

Example 2: Higher-Order Denominator


For:
4
G(s) =
s5 +7
Include zero coefficients for missing powers:
1 num = [4];
2 den = [1 , 0 , 0 , 0 , 0 , 7];
3 G = tf ( num , den ) ;

Example 3: Direct Polynomial Representation


For:
4s
G(s) =
s3 +s+5
Define s as a transfer function variable:
1 s = tf ( ’s ’) ;
2 G = 4 * s / ( s ^3 + s + 5) ;

Example 4: Zero-Pole-Gain Representation


For:
4s(s + 1)
G(s) =
(s + 5)(s − 4)
Use the zpk function (zeros, poles, gain):
1 G = zpk ([0 , -1] , [ -5 , 4] , 4) ;

Mohammad Abrar Kabir, IUT, EEE


Control System Engineering Lab 7

Example 5: Polynomial Multiplication


For:
s2 + 5s + 9
G(s) =
(s3 + 7s2 + s)(s − 4)
Use conv to multiply denominator polynomials:
1 num = [1 , 5 , 9];
2 den = conv ([1 , 7 , 1 , 0] , [1 , -4]) ;
3 G = tf ( num , den ) ;

3.2 Analyzing Transfer Functions


Example 6: Extracting Poles, Zeros, and Gain
For the transfer function from Example 5:
s2 + 5s + 9
G(s) =
(s3 + 7s2 + s)(s − 4)
Extract zeros, poles, and gain using tf2zp:
1 num = [1 , 5 , 9];
2 den = conv ([1 , 7 , 1 , 0] , [1 , -4]) ;
3 G = tf ( num , den ) ;
4 [z , p , k ] = tf2zp ( num , den ) ;

Example 7: Transfer Function from Poles, Zeros, and Gain


Given poles at −3, 1, zero at −1, and gain 10:
1 P = [ -3 , 1];
2 Z = [ -1];
3 K = 10;
4 [ num , den ] = zp2tf (Z , P , K ) ;
5 G = tf ( num , den ) ;

Note: Use column vectors for Z and P.

Plotting Poles and Zeros


To plot poles (marked as ’x’) and zeros (marked as ’o’), use pzmap:
1 pzmap ( G ) ;

3.3 System Responses


Example 8: Pole-Zero Map with Complex Poles
For:
s2 + 7s + 10
G(s) = 3
s + 6s2 + 10s + 8
Plot the pole-zero map (complex poles appear as conjugates):

Mohammad Abrar Kabir, IUT, EEE


Control System Engineering Lab 8

1 G = tf ([1 , 7 , 10] , [1 , 6 , 10 , 8]) ;


2 sgrid ;
3 pzmap ( G ) ;

Impulse Response
For the system in Example 8:
1 impulse ( G ) ;

Step Response
For the same system:
1 step ( G ) ;

Ramp Response
1
MATLAB lacks a direct ramp response command. Multiply the transfer function by s
and
take the step response. For Example 9:
s2 + 7s + 10 s2 + 7s + 10
G(s) = , H(s) =
s3 + 6s2 + 10s + 8 s(s3 + 6s2 + 10s + 8)
1 H = tf ([1 , 7 , 10] , [1 , 6 , 10 , 8 , 0]) ;
2 pzmap ( H ) ;
3 figure (2) ;
4 step ( H ) ;

Arbitrary Response
Use lsim for arbitrary inputs (e.g., exponential input):
1 num = [1 , 5];
2 den = [1 , 4];
3 t = 0:0.1:5;
4 r = exp ( t ) ;
5 y = lsim ( num , den , r , t ) ;
6 plot (t , y ) ;

3.4 Feedback Control Systems


For:
2s2 + 5s + 1 5(s + 2)
G(s) = , H(s) =
s2 + 2s + 3 s + 10
Apply negative feedback (default in feedback):
1 G = tf ([2 , 5 , 1] , [1 , 2 , 3]) ;
2 H = zpk ( -2 , -10 , 5) ;
3 Cloop = feedback (G , H ) ;
4 step ( Cloop ) ;

Mohammad Abrar Kabir, IUT, EEE


Control System Engineering Lab 9

For positive feedback, use feedback(G, H, +1).

4 Assignment
4.1 RC Circuit – Step Response Analysis
• Derive the differential equation and transfer function of a series RC circuit (with R = 1 Ω,
C = 1 F).
• Use MATLAB to plot the step response using the tf and step functions.
• Implement the same circuit in Simulink using both the S-domain and time domain ap-
proach.
• Compare both responses and explain your observation.

4.2 Transfer Function Representation and Pole-Zero Mapping


5(s+3)
• Consider the system G(s) = s3 +4s2 +6s+2
.
• Represent it using:
– Coefficient vectors with tf
– Zero-pole-gain with zpk
– Symbolic transfer function with s = tf(’s’)
• Plot the pole-zero map.
• Identify stability and transient behavior based on the pole positions.

4.3 RLC Circuit – Multi-Method Step Response


• Consider a second-order RLC circuit with a time-varying input voltage source. The
output voltage is observed across the capacitor.
• Use the following values: R = 40 Ω, C = 0.25 F, L = 4 H.
Vout (s)
• Derive the transfer function Vin (s)
, where the output is across the capacitor.
• Plot the step response using:
– MATLAB coding
– Simulink LTI block
– Simulink time-domain implementation
• Compare and explain the differences in responses.

4.4 Impulse and Ramp Response for a Second-Order System


1
• Given G(s) = s2 +3s+2

• Plot the impulse response using impulse(G).


G(s)
• Plot the ramp response by taking the step response of s
.

Mohammad Abrar Kabir, IUT, EEE


Control System Engineering Lab 10

• Explain the system behavior under both inputs.


• Determine the damping ratio and natural frequency from the denominator.

4.5 Stability Comparison – Feedback Systems


2s+5 1
• Given open-loop transfer function: G(s) = s2 +3s+4
, and feedback path H(s) = s+2

• Implement closed-loop systems with:


– Negative feedback
– Positive feedback
• Plot step responses and compare overshoot, settling time, and stability.
• Analyze the effect of feedback polarity on pole locations.

4.6 Arbitrary Input and Realistic Modeling


• Define the input: vin (t) = 5e−0.5t sin(3t)
1
• Use an RC circuit with transfer function G(s) = RCs+1
, where R = 1 Ω, C = 0.1 F.
• Plot the response using:
– lsim in MATLAB
– Simulink with signal builder or function generator
• Discuss how the circuit behaves as a filter.
• Comment on practical implications in signal processing or audio systems.

4.7 Op-Amp 1st Order Circuit Modeling

Find the step response vo (t) for t > 0 in the op amp circuit . Let vi = 2u(t) V, R1 = 20 kΩ,
Rf = 50 kΩ, R2 = R3 = 10 kΩ, C = 2 µF.
Vout (s)
• Derive the transfer function Vin (s)
, where the output is across the capacitor.
• Plot the step response using:

Mohammad Abrar Kabir, IUT, EEE


Control System Engineering Lab 11

– MATLAB coding
– Simulink LTI block
– Simulink time-domain implementation

Mohammad Abrar Kabir, IUT, EEE

You might also like