the System states behave equally with the implementation of a linear model predictive control

1 Ansicht (letzte 30 Tage)
I have implemented the following model predictive control algorithm in MATLAB. the idea is to write the system state forward in time in terms of the previous inputs and states. Doing so, the cost function of the Optimal Control problem over a known horizon should be minimized to drive the control signal. The following is my code:
clc;clear;close all;
Ts = 0.01;
tMax = 5;
t = 0:Ts:tMax;
s = tf('s');
G = (0.03*s+1)/(s^2-5*s+2);
G = c2d(G,Ts);
StateSpace = ss(G);
A = StateSpace.A;
eig(A)
B = StateSpace.B;
C = StateSpace.C;
D = StateSpace.D;
Np = 3;
n = size(A,2);
m = size(B,2);
ABAR = [eye(size(A))
A
A^2
A^3];
BBAR = [zeros(n,m) zeros(n,m) zeros(n,m)
B zeros(n,m) zeros(n,m)
A*B B zeros(n,m)
A^2*B A*B B];
% CBAR = zeros(((Np)*m),((Np)*n));
% for i=1:Np
%
% CBAR(i*m-(m-1):i*m,1:n) = C*A^(i);
%
% end
% DBAR = zeros(((Np)*m),((Np)*m));
%
% DBAR = ...
% [C*B 0 0
% C*A*B C*B 0
% C*A^2*B C*A*B C*B];
N = numel(t);
r = 0.1;
q = 1;
RBAR = r*eye((Np*m),(Np*m));
QBAR = q*eye(((Np+1)*n),((Np+1)*n));
T = (BBAR'*QBAR*BBAR+RBAR)^-1*BBAR'*QBAR;
K = (BBAR'*QBAR*BBAR+RBAR)^-1*BBAR'*QBAR*ABAR;
UBAR = ones(m*Np,N);
Ref = ones((Np+1)*n,N+1);
% Ref(1,:) = ones(1,N+1);
% Ref(2,:) = zeros(1,N+1);
%
% Ref(3,:) = ones(1,N+1);
% Ref(4,:) = zeros(1,N+1);
%
% Ref(5,:) = ones(1,N+1);
% Ref(6,:) = zeros(1,N+1);
x = zeros(n,N);
for i=2:N
x(:,i) = A*x(:,i-1) + B*UBAR(1,i-1);
UBAR(:,i) = T*Ref(:,i+1) - K*x(:,i);
end
f1 = figure(1);
subplot 211
plot(t,x(1,:),'LineWidth',2)
grid on
legend('x_{1}')
subplot 212
plot(t,x(2,:),'Color',[0.5 0.1 0.3],'LineWidth',2)
grid on
legend('x_{2}')
f2 = figure(2);
plot(t,UBAR(1,:),'R','LinEwIDth',2)
grid on
xlabel('Time (s)')
legend('u')
movegui(f1,'east')
movegui(f2,'west')
And the results I'm getting are shown:
My problem is that the system is stable yet both state variables are exactly the same. I do not know whether the control signal is being drived correctly or not. Can somone help me?

Antworten (0)

Kategorien

Mehr zu Model Predictive Control Toolbox finden Sie in Help Center und File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by