You are on page 1of 4

Adaptive Control Systems Assignment-2

Abdullah — Younas Kayani — MSSE 21-23 — Semester-3

December 1, 2022

Equations
System Equations
ẋ = Ax + Ψ(y, u) + Φ(x, θ, u)
y = Cx
(1)
Φ(x, θ, u) = Φ1 (x, u) + BΦ2 (x, u)θ
Φ1 = 0, Φ2 = −15.86 sin x3

Adaptive State Observer


x̂˙ = Ax̂ + Ψ(y, u) + Φ(x̂, θ̂, u) − L(y − C x̂)
Φ(x̂, θ̂, u) = Φ1 (x, u) + BΦ′2 (x̂, u)θ̂ (2)
Φ1 = 0, Φ′2 = −15.86 sin xˆ3

Parameter Adaptation Law


˙
θ̂ = ΓΦ′2 (x̂, u)T (y − C x̂)
(3)
Γ=5

Excitation Input
u = sin 2πt; (4)

Simulation
The aforementioned equations were simulated using MATLAB. These equations are given by Ekramian et al. (2013).
In this simulation we have tried to reproduce the results that they have achieved.
The true value of the parameter ’m’ witches between a few constant value in order to observe how quickly the
adaptation law adapts the value of the estimated parameter to converge to the value of ’m’. This is implemented
in the function ’theta’ given below:

function theta = theta ( t )

if ( t < 1) && (t >=0)


theta = 0.25;
elseif ( t < 2) && (t >=1)
theta = 1.5;
else
theta = 0.75;
end

end

1
All of the equations were written inside of a function ’model’. The contents of this function are given below:

function dx = model (t , X )

x = X (1:4) ;
x_hat = X (5:8) ;
theta_hat = X (9) ;

d_x = zeros (4 ,1) ;


d_x_hat = zeros (4 ,1) ;
d_theta_hat = zeros (1 ,1) ;

u = sin (2* pi * t ) ;

A = [0 0 0 1; 19.5 0 -19.5 0; 0 1 0 0; -48.6 0 48.6 -1.25];


psi = [0; 0; 0; 21.6* u ];
B = [0; 1; 0; 0];
C = [1 0 0 0; 0 1 0 0];
T = [ -1.129 3.8880];
L_dash = -[7.618 2.213 5.606 18.80;
2.231 46.23 1.628 5.464];
L = L_dash ’;
Gamma = 5;

phi_1 = 0;
phi_2 = -15.86 * sin ( x (3) ) ;
phi = phi_1 + B * phi_2 * theta ( t ) ;

phi_2_dash = -15.83* sin ( x_hat (3) ) ;


phi_adp = phi_1 + B * phi_2_dash * theta_hat ;

d_x = A * x + psi + phi ;


y = C*x;

d_theta_hat = Gamma * phi_2_dash * T *( y - C * x_hat ) ;

d_x_hat = A * x_hat + psi + phi_adp - L *( y - C * x_hat ) ;

dx = [ d_x ; d_x_hat ; d_theta_hat ];

end

2
Finally the main simulation file is given below, which solves the differential equations using ode45 function of
MATLAB. The main code also has the plots that are given in the next section.

% % Clearing workspace , command window and closing all open figures


clc
clear ;
close all ;

% % Initial conditions
x_0 = [1 -1 1 5] ’;
x_0_hat = [1 -1 0 0 ] ’;
m_0 = 0.5;

x0 = [ x_0 ’ x_0_hat ’ m_0 ];

% % Solving the system of differential equations


[T , dx ] = ode45 ( @model ,[0 2.5] , x0 ) ;

% % Changing true value of m


for i =1: length ( T )
m ( i ) = theta ( T ( i ) ) ;
end

% % Plots
figure (1)

subplot (3 ,1 ,1)
hold on
plot (T , dx (: ,3) )
plot (T , dx (: ,7) , ’r -. ’)
legend ( ’ Actual State ’ , ’ Adapive State ’)
ylabel ( ’ State x_3 ’)
hold off

subplot (3 ,1 ,2)
hold on
plot (T , dx (: ,4) )
plot (T , dx (: ,8) , ’r -. ’)
ylabel ( ’ State x_4 ’)
legend ( ’ Actual State ’ , ’ Adapive State ’)
hold off

subplot (3 ,1 ,3)
hold on
plot (T , m )
plot (T , dx (: ,9) , ’r -. ’)
ylabel ( ’ Parameter m ’)
xlabel ( ’ Time ’)
legend ( ’ Actual Value ’ , ’ Adapive Value ’)
hold off

3
Plots

Figure 1: Plot of states x3 and x4 of the system given in equation 1 with the control law of equation
4 applied. The estimation of the states x3 and x4 made using the adaptive state observer given in
equation 2 is also superimposed on the true values of the states. In the last plot, the estimated
and the actual value of the parameter ’m’ is compared where the actual value of the parameter is
constant but changes twice to see the effect on the estimated value.

References
Ekramian, M., Sheikholeslam, F., Hosseinnia, S., and Yazdanpanah, M. (2013). Adaptive state observer for lipschitz
nonlinear systems. Systems & Control Letters, 62(4):319–323.

You might also like