Group 4 Pole
Group 4 Pole
Group 4 Pole
S/No Names CA No
*It is noted that the command eig (A-B*K) may be used to verify that K thus
obtained gives the desired eigenvalues.
EXAMPLE:
= Ax + Bu
Where:
A = and B=
By using state feedback control (u=-Kx), it is desired to have the closed-loop poles
at s= (i=1, 2, 3), where
Consider the same system as discussed in Example above. It is desired that this
regulator system have closed-loop poles at
s = -2 + j4, s = -2 - j4, s = -10
The necessary state feedback gain matrix K was obtained in Example above as
follows:
K = [199 55 8]
Using MATLAB, obtain the response of the system to the following initial condition:
We are required to Plot graph using MATLAB to show trajectory response of x1,x2,x3
Lets solve it using MATLAB:
Certainly! Let's go through the code step by step and explain the purpose of each
section:
Because we use as example before this we can show matrix we have on our system:
In MATLAB by using this codes
% Define the system matrices
A = [0 1 0; 0 0 1; -1 -5 -6];
B = [0; 0; 1];
C = [1 0 0];
D = 0;
In the section above , we define the system matrices: A, B, C, and D. These matrices represent
the state-space representation of the system. Matrix A represents the dynamics of the system,
matrix B represents the input to the system, matrix C represents the output of the system, and
matrix D represents the feedthrough term.
% Specify the desired pole locations
desired_poles = [-2+4j, -2-4j, -10];
Here, we specify the desired pole locations for the closed-loop system. These pole locations
determine the system's dynamic response. In this example, the desired poles are specified as
complex numbers -2+4j, -2-4j, and real number -10.
% Calculate the feedback gain matrix using the desired poles
K = acker(A, B, desired_poles);
In this step, the acker function is used to calculate the feedback gain matrix K based on the
desired pole locations. The acker function determines the appropriate feedback gain matrix to
achieve the desired pole locations, ensuring the desired system response.
And the K will be the same as mentioned in the Question above you can prefer to not go through
all this and instead you can just input all details as given in the question but we choose to start from
beginning to show how exactly this can be done
% Define the closed-loop system
sys_cl = ss(A - B*K, B, C, D);
Here, we define the closed-loop system by subtracting the product of matrices B
and K from matrix A. The resulting state-space model sys_cl represents the closed-
loop system with the calculated feedback gain matrix K. The closed-loop system is
defined using the ss function.
% Define the initial condition
x0 = [1; 0; 0];
In this step, we define the initial condition x0 for the state variables of the system.
The initial condition represents the initial values of the states x1, x2, and x3 at time
t=0. In this example, the initial condition is set to [1; 0; 0], which means x1(0) = 1,
x2(0) = 0, and x3(0) = 0.
% Simulate the system response
t = 0:0.01:10; % Time vector
[y, t, x] = lsim(sys_cl, zeros(size(t)), t, x0);
In that section in previous slide, we simulate the system response using the lsim
function. We specify the closed-loop system sys_cl, zero input (zeros(size(t))),
time vector t, and the initial condition x0. The lsim function computes the system
response and returns the output y, time vector t, and state trajectory x.
% Extract the states from the state trajectory
x1 = x(:, 1);
x2 = x(:, 2);
x3 = x(:, 3);
Here, we extract the individual states (x1, x2, x3) from the state trajectory x
obtained from the simulation. This allows us to plot each state separately.
% Plot the state responses
subplot(3, 1, 1);
plot(t, x1);
xlabel('Time');
ylabel('x1');
title('State x1 vs Time');
subplot(3, 1, 2);
plot(t, x2);
xlabel('Time');
ylabel('x2');
title('State x2 vs Time');
subplot(3, 1, 3);
plot(t, x3);
xlabel('Time');
ylabel('x3');
title('State x3 vs Time');
In that section in previous slide, we use the subplot function to create three
separate subplots for each state (x1, x2, x3). We plot each state response against
time using the plot function. The xlabel, ylabel, and title functions are used to label
the axes and provide titles for each subplot.
Result: