How to create a state space model with constant term and do feedback.
18 次查看(过去 30 天)
显示 更早的评论
I have the discrete time system -
x(k+1) = [A]*x(k) + [B]*u(k) + c
y(k) = [C]*x(k)
I have read online that I can merge the constant term into B by doing [B 1] * [u1(k) ; u2(k)] with u2(k) = c ( I have no control over this input). ie the system becomes
x(k+1) = [A]*x(k) + [B 1]*[u1(k) ; c]
y(k) = [C]*x(k).
However, when I do state feed back, how can I ensure that u2(k) = c?
3 个评论
Sam Chak
2024-10-16
You appear to have used the continuous-time linear system to place the discrete-time closed-loop pole inside the unit circle (stable region of discrete-time linear system), which is considered incorrect.
采纳的回答
更多回答(2 个)
Aquatris
2024-10-15
You can define which inputs and outputs are connected to your controller. Checkout the feedback function page and look at the 'Specify Input and Output Connections in a Feedback Loop' section.
First try it yourself to figure it out, cause it is a nice exercise to understand documentation and how to search for things. If you get stuck while doing it, provide what you have done and we can guide you.
3 个评论
Aquatris
2024-10-15
编辑:Aquatris
2024-10-15
It is a general representation. State feedback essentially means your observation matrix C is identity matrix with a size of nxn where n is the number of states.
So in addition to your actual output, you can create another output for your feedback controller that would have the state information, something like:
Then you need to connect the y_states as an input to your feedback controller and connect u1 to the output of your feedback controller
Pavl M.
2024-11-8,16:58
编辑:Pavl M.
2024-11-8,16:59
There are 2 simple precise ways to do it:
Just make your
Baug = [B 1]
and regard your c = u2(k) as constant control input to your plant(environment) with u1(k) as the control from the controller(agent) you are designing.
then
sys1 = ss(A,Baug,C,D,Ts)
K = place(A,Baug,0.5);
G = inv(C*inv(1-(A-Baug*K))*Baug);
cldyn = ss(A-Baug*K,Baug*G,C,D,Ts)
or treat the c as a noise(disturbance), then don't augment much your B, leave it as B ( I worked on it ) and use disturbance rejection PID or LQR next controller:
with defining state cost, control cost and cross control-state cost matrices as per your problem objections and econometrics,
use lqgtrack or lqg or Kalman:
%State cost matrix:
Q1 = gain*eye(A_size_row+aug_level+1);
Q2 = gain*eye(A_size_row+aug_level);
%Control cost matrix:
%symmetric positive semi-definite state cost matrix, and R (k × k) is a symmetric positive definite control cost matrix.
R = eye(n_states,n_states); %eye(size(A));
%Cross Control-state cost:
N = 1; %eye(A_size_row,length(C));
S = eye(n_states,n_outputs);
E = eye(n_states,n_states);
[~,p] = chol(R)
CM = [Q2;N;N';R]
##Function File: [G, X, L] = dlqr (SYS, Q, R)
## -- Function File: [G, X, L] = dlqr (SYS, Q, R, S)
## -- Function File: [G, X, L] = dlqr (A, B, Q, R)
## -- Function File: [G, X, L] = dlqr (A, B, Q, R, S)
## -- Function File: [G, X, L] = dlqr (A, B, Q, R, [], E)
## -- Function File: [G, X, L] = dlqr (A, B, Q, R, S, E)
## Linear-quadratic regulator for discrete-time systems.
##
## *Inputs*
## SYS
## Continuous or discrete-time LTI model (p-by-m, n states).
## A
## State transition matrix of discrete-time system (n-by-n).
## B
## Input matrix of discrete-time system (n-by-m).
## Q
## State weighting matrix (n-by-n).
## R
## Input weighting matrix (m-by-m).
## S
## Optional cross term matrix (n-by-m). If S is not specified, a
## zero matrix is assumed.
## E
## Optional descriptor matrix (n-by-n). If E is not specified,
## an identity matrix is assumed.
##
## *Outputs*
## G
## State feedback matrix (m-by-n).
## X
## Unique stabilizing solution of the discrete-time Riccati
## equation (n-by-n).
## L
## Closed-loop poles (n-by-1).
##
## *Equations*
## x[k+1] = A x[k] + B u[k], x[0] = x0
##
## inf
## J(x0) = SUM (x' Q x + u' R u + 2 x' S u)
## k=0
##
## L = eig (A - B*G)
[K1,XG1,L1] = lqi(sys,Q1,R)
[G, X, L] = dlqr (A, B, Q2, R,S)
[Fr,Pr,Er]=lqrpid(sys,Q,R)
%dare provides similar to dlqr results
%QXU =
%QWV =
%QI =
%https://www.mathworks.com/help/control/getstart/design-an-lqg-servo-controller.html
%reg = lqg(sys,QXU,QWV,QI)
K_i = -min(X3)
K_x = -X3
%Hamiltonian:
H = A - B*G;
p = 0.5;
%poles placement control:
Ka=acker(A, B, p)
A2 = A - Ka*B
Hope this clears up full solution to your conundrum. For complete solution help me financially if you wanna I do it for you. I have had been developing 3/4 of the disturbance rejection, contact me more for exact codes if you are interested.
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!