PFC controller for stable system
I wrote code for the PFC controller to control a stable system to track to the desired value (in this one) but the system became unstable and I can not understand why the PFC controller was designed to make a stable system unstable. Code I wrote as follows
t0 = 0 ;
tf = 40;
ts = 0.01;
t = t0:ts:tf ;
Am = [0,0,0,0,0,1,0,0,0,0;0,0,0,0,0,0,1,0,0,0;0,0,0,0,0,0,0,1,0,0;0,0,0,0,0,0,0,0,1,0;0,0,0,0,0,0,0,0,0,1;-1967.63005780347,983.815028901734,0,0,0,-16.9768786127168,8.48843930635838,0,0,0;983.815028901734,-1967.63005780347,983.815028901734,0,0,8.48843930635838,-16.9768786127168,8.48843930635838,0,0;0,983.815028901734,-1967.63005780347,983.815028901734,0,0,8.48843930635838,-16.9768786127168,8.48843930635838,0;0,0,983.815028901734,-1967.63005780347,983.815028901734,0,0,8.48843930635838,-16.9768786127168,8.48843930635838;0,0,0,983.815028901734,-983.815028901734,0,0,0,8.48843930635838,-8.48843930635838];
Bm = [0,0,0,0,0;0,0,0,0,0;0,0,0,0,0;0,0,0,0,0;0,0,0,0,0;-0.00289017341040462,0,0,0,0;0,-0.00289017341040462,0,0,0;0,0,-0.00289017341040462,0,0;0,0,0,-0.00289017341040462,0;0,0,0,0,-0.00289017341040462];
Cm = [1,0,0,0,0,0,0,0,0,0;0,1,0,0,0,0,0,0,0,0;0,0,1,0,0,0,0,0,0,0;0,0,0,1,0,0,0,0,0,0;0,0,0,0,1,0,0,0,0,0;0,0,0,0,0,1,0,0,0,0;0,0,0,0,0,0,1,0,0,0;0,0,0,0,0,0,0,1,0,0;0,0,0,0,0,0,0,0,1,0;0,0,0,0,0,0,0,0,0,1]; ;
n = size(Am ,1) ; % number of eigenvalues
q = size(Cm , 1) ; % number of outputs
m = size(Bm , 2) ; % number of inputs
Np =15 ; % Prediction Horizon
Nc = 10; % Control Horizon
F = zeros(q*Np , size(Am , 1)) ;
for i = 1:Np
F(q*i-q+1:q*i , 🙂 = Cm * Am^i ;
end
PHI = zeros(q * Np , m*Nc);
for i = 1:Np
for j = 1:i
PHI(q*i-q+1:q*i , m*j-m+1:m*j) = Cm * Am^(i-j) * Bm ;
end
end
PHI = PHI( : , 1:Nc*m) ;
%% Main Loop
Nt = numel(t) ;
y = zeros(q , Nt) ;
du = zeros(m , Nt) ;
x = zeros(size(Am , 1) , Nt) ;
R = 1 ;
Fval = zeros(Nt , 1 ) ;
for i = 1:Nt-1
FreeResponse = F * x(: , i);
dU = (PHI’*PHI + R * size(PHI , 2))(PHI’ * (1 – FreeResponse)) ;
du(: , i) = dU(1:m) ;
x(: , i+1) = Am * x(: , i) + Bm * du(: ,i) ;
y(: , i+1) = Cm * x(: , i+1) ;
endI wrote code for the PFC controller to control a stable system to track to the desired value (in this one) but the system became unstable and I can not understand why the PFC controller was designed to make a stable system unstable. Code I wrote as follows
t0 = 0 ;
tf = 40;
ts = 0.01;
t = t0:ts:tf ;
Am = [0,0,0,0,0,1,0,0,0,0;0,0,0,0,0,0,1,0,0,0;0,0,0,0,0,0,0,1,0,0;0,0,0,0,0,0,0,0,1,0;0,0,0,0,0,0,0,0,0,1;-1967.63005780347,983.815028901734,0,0,0,-16.9768786127168,8.48843930635838,0,0,0;983.815028901734,-1967.63005780347,983.815028901734,0,0,8.48843930635838,-16.9768786127168,8.48843930635838,0,0;0,983.815028901734,-1967.63005780347,983.815028901734,0,0,8.48843930635838,-16.9768786127168,8.48843930635838,0;0,0,983.815028901734,-1967.63005780347,983.815028901734,0,0,8.48843930635838,-16.9768786127168,8.48843930635838;0,0,0,983.815028901734,-983.815028901734,0,0,0,8.48843930635838,-8.48843930635838];
Bm = [0,0,0,0,0;0,0,0,0,0;0,0,0,0,0;0,0,0,0,0;0,0,0,0,0;-0.00289017341040462,0,0,0,0;0,-0.00289017341040462,0,0,0;0,0,-0.00289017341040462,0,0;0,0,0,-0.00289017341040462,0;0,0,0,0,-0.00289017341040462];
Cm = [1,0,0,0,0,0,0,0,0,0;0,1,0,0,0,0,0,0,0,0;0,0,1,0,0,0,0,0,0,0;0,0,0,1,0,0,0,0,0,0;0,0,0,0,1,0,0,0,0,0;0,0,0,0,0,1,0,0,0,0;0,0,0,0,0,0,1,0,0,0;0,0,0,0,0,0,0,1,0,0;0,0,0,0,0,0,0,0,1,0;0,0,0,0,0,0,0,0,0,1]; ;
n = size(Am ,1) ; % number of eigenvalues
q = size(Cm , 1) ; % number of outputs
m = size(Bm , 2) ; % number of inputs
Np =15 ; % Prediction Horizon
Nc = 10; % Control Horizon
F = zeros(q*Np , size(Am , 1)) ;
for i = 1:Np
F(q*i-q+1:q*i , 🙂 = Cm * Am^i ;
end
PHI = zeros(q * Np , m*Nc);
for i = 1:Np
for j = 1:i
PHI(q*i-q+1:q*i , m*j-m+1:m*j) = Cm * Am^(i-j) * Bm ;
end
end
PHI = PHI( : , 1:Nc*m) ;
%% Main Loop
Nt = numel(t) ;
y = zeros(q , Nt) ;
du = zeros(m , Nt) ;
x = zeros(size(Am , 1) , Nt) ;
R = 1 ;
Fval = zeros(Nt , 1 ) ;
for i = 1:Nt-1
FreeResponse = F * x(: , i);
dU = (PHI’*PHI + R * size(PHI , 2))(PHI’ * (1 – FreeResponse)) ;
du(: , i) = dU(1:m) ;
x(: , i+1) = Am * x(: , i) + Bm * du(: ,i) ;
y(: , i+1) = Cm * x(: , i+1) ;
end I wrote code for the PFC controller to control a stable system to track to the desired value (in this one) but the system became unstable and I can not understand why the PFC controller was designed to make a stable system unstable. Code I wrote as follows
t0 = 0 ;
tf = 40;
ts = 0.01;
t = t0:ts:tf ;
Am = [0,0,0,0,0,1,0,0,0,0;0,0,0,0,0,0,1,0,0,0;0,0,0,0,0,0,0,1,0,0;0,0,0,0,0,0,0,0,1,0;0,0,0,0,0,0,0,0,0,1;-1967.63005780347,983.815028901734,0,0,0,-16.9768786127168,8.48843930635838,0,0,0;983.815028901734,-1967.63005780347,983.815028901734,0,0,8.48843930635838,-16.9768786127168,8.48843930635838,0,0;0,983.815028901734,-1967.63005780347,983.815028901734,0,0,8.48843930635838,-16.9768786127168,8.48843930635838,0;0,0,983.815028901734,-1967.63005780347,983.815028901734,0,0,8.48843930635838,-16.9768786127168,8.48843930635838;0,0,0,983.815028901734,-983.815028901734,0,0,0,8.48843930635838,-8.48843930635838];
Bm = [0,0,0,0,0;0,0,0,0,0;0,0,0,0,0;0,0,0,0,0;0,0,0,0,0;-0.00289017341040462,0,0,0,0;0,-0.00289017341040462,0,0,0;0,0,-0.00289017341040462,0,0;0,0,0,-0.00289017341040462,0;0,0,0,0,-0.00289017341040462];
Cm = [1,0,0,0,0,0,0,0,0,0;0,1,0,0,0,0,0,0,0,0;0,0,1,0,0,0,0,0,0,0;0,0,0,1,0,0,0,0,0,0;0,0,0,0,1,0,0,0,0,0;0,0,0,0,0,1,0,0,0,0;0,0,0,0,0,0,1,0,0,0;0,0,0,0,0,0,0,1,0,0;0,0,0,0,0,0,0,0,1,0;0,0,0,0,0,0,0,0,0,1]; ;
n = size(Am ,1) ; % number of eigenvalues
q = size(Cm , 1) ; % number of outputs
m = size(Bm , 2) ; % number of inputs
Np =15 ; % Prediction Horizon
Nc = 10; % Control Horizon
F = zeros(q*Np , size(Am , 1)) ;
for i = 1:Np
F(q*i-q+1:q*i , 🙂 = Cm * Am^i ;
end
PHI = zeros(q * Np , m*Nc);
for i = 1:Np
for j = 1:i
PHI(q*i-q+1:q*i , m*j-m+1:m*j) = Cm * Am^(i-j) * Bm ;
end
end
PHI = PHI( : , 1:Nc*m) ;
%% Main Loop
Nt = numel(t) ;
y = zeros(q , Nt) ;
du = zeros(m , Nt) ;
x = zeros(size(Am , 1) , Nt) ;
R = 1 ;
Fval = zeros(Nt , 1 ) ;
for i = 1:Nt-1
FreeResponse = F * x(: , i);
dU = (PHI’*PHI + R * size(PHI , 2))(PHI’ * (1 – FreeResponse)) ;
du(: , i) = dU(1:m) ;
x(: , i+1) = Am * x(: , i) + Bm * du(: ,i) ;
y(: , i+1) = Cm * x(: , i+1) ;
end mpc, pfc MATLAB Answers — New Questions
​