Resetting only a section of my state during event driven ode45 simulation
3 views (last 30 days)
Show older comments
Hello,
I'm trying to write a code that simulates a closed loop event driven LTI system (with a poleplacement controller u(t) = -K*x(t)). I'm using the following event formulation:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1703901/image.png)
where the ξ stands for the actual state and the ϵ stands for the error between the current state and the state measured during an event trigger. So:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1703931/image.png)
So I want to trigger an event the moment the
value becomes 0.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1703936/image.png)
Now, the problem I'm having is that I want the ϵ value (so the error) to reset to 0 upon an event but the ξ part of the state should not reset. I'm having trouble coming up with a way to exactly program this. I'm currently just simulating the system dynamics for the augmented system, so for
. For now I have the following in matlab:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1703941/image.png)
a = 4;
b = 6;
c = 9;
poles = [-1+2i; -1-2i];
A = [0.3+a-b, 0.5-c; 0, 1];
B = [0; 1];
C = eye(2);
D = [0; 0];
K = place(A, B, poles);
A_aug = [A-B*K -B*K;
-A+B*K B*K];%Defining augmented CL A-matrix for augmented state x_augmented = [x;error]//[xi;epsilon]
tspan = [0,10];
x0 = [1;1;0;0];
Q = eye(2);
P = 2*eye(2);
sig = 0.1;
options = odeset('Events', @(t,x) myEventsFcn(t,x,sig,Q,P,B,K));
[t,y,te,ye,ie] = ode45(@(t,x) LTIaug_fun(t,x,A_aug),tspan,x0,options)
Where the LTIaug_fun and myEventsFcn are defined as follows:
function dxdt = LTIaug_fun(~,x,A_aug)
dxdt = A_aug*x;
end
function [value,isterminal,direction] = myEventsFcn(t,x,sig,Q,P,B,K)
Th = [(1-sig)*Q P*B*K;
(B*K)'*P zeros(2,2)];
Th_e = x'*Th*x;
value = Th_e;
isterminal = 1;
direction = 0;
end
So how do I set my ϵ part of my augmented state to 0 after/during an event trigger?
0 Comments
Answers (1)
See Also
Categories
Find more on Ordinary Differential Equations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!