ans(t) = ![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1746011/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1746011/image.png)
Hi @Le,
To adress your query regarding, “can you help me replace state feedback controller by event trigggered control u(i,j) =K[x^h(i_p,j);x^v(i,j_q)]?”
To replace the state feedback controller with event-triggered control in your given code, you need to make several modifications: first define the triggering conditions by assuming that the triggering condition is based on the difference between the current state and the previous state. Then, modify the control update only when the triggering condition is satisfied. This can be done by adding an if statement to check if the triggering condition is met. If it is, we will update the control action; otherwise, keep the previous control action. Since event-triggered control is being utilized, the state variables will be updated only when the control action is updated. Therefore, modifying the code to update the state variables accordingly. Here is your modified code:
% Closed-loop system
A = [0.5 1; 0.45 0.85];
A_d = [0.04 0.1; 0.1 0.2];
B = [1.5; 1.3];
D = [0.5; 0.4];
g = 7;
K = [-0.3202 -0.7155];
A_c = A + B * K;
n = 40;
v = zeros(1, n);
w = zeros(1, n);
Xh = zeros(n, n);
Xv = zeros(n, n);
U = zeros(n, n);
W = zeros(n, n);
prev_control = zeros(2, 1); % Initialize previous control action
for i = 1:1:10
Xh(1, i) = 0;
end
for i = 11:1:n-1
Xh(1, i) = 0;
end
for i = 1:1:10
Xv(i, 1) = 0;
end
for i = 11:1:n-1
Xv(i, 1) = 0;
end
x1 = zeros(2, 1);
x0 = zeros(2, 1);
xt = zeros(2, 1);
xd = ones(2, 1);
for i = 1:1:n
v(1, i) = i;
w(1, i) = i;
end
for s = 1:1:4
for i = s:1:4
x0(1, 1) = Xh(s, i);
x0(2, 1) = Xv(s, i);
x1 = (A_c * x0) + (D * (9 * exp(-0.065 * pi * (s + i))));
Xh(s + 1, i) = x1(1, 1);
Xv(s, i + 1) = x1(2, 1);
% Check triggering condition and update control action
if norm(x1 - prev_control) > threshold
U(s, i) = K * x0;
prev_control = U(s, i);
else
U(s, i) = prev_control;
end
W(s, i) = 9 * exp(-0.065 * pi * (s + i));
end
end
After the last end statement, the rest of your code remains the same. So, in this modified code, you can see an if statement is added to check the triggering condition before updating the control action. The triggering condition is based on the difference between the current state x1 and the previous control action prev_control. If the difference exceeds a certain threshold, control action is updated, otherwise, you need to keep the previous control action. Please note that you need to define the threshold value based on your specific requirements. The threshold determines how much the state needs to change before triggering a control update. By implementing this event-triggered control, you can reduce the computational burden and improve the efficiency of the control system. The control action will only be updated when necessary, leading to better resource utilization and potentially improved system performance. I hope this helps! Let me know if you have any further questions.
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!