------------------------ ----------------------%
% Знаходження елементів матриць Q і R
r (1) = 100;
q (1) = 1/poryadok * r (1) * (U_max) ^ 2/(X_max (1)) ^ 2;
В
for i = 2: poryadok
q (i) = q (1) * (X_max (1)) ^ 2/(X_max (i)) ^ 2;
end
Q = diag (q);
R = diag (r);
В
% Для зміни коефіцієнтів
% Q (1,1) = Q (1,1) * 1e +13;
% Q (2,2) = Q (2,2) * 1e +10;
% Q (3,3) = Q (3,3) * 1e +8;
% Q (4,4) = Q (4,4) * 1e +5;
% Q (5,5) = Q (5,5) * 1e +2;
В
R (1,1) = R (1,1);
% -------------------------------------------------- ----------------------%
% ------------------ Ковзні інтервали ------------------------------ ----%
shag = Time/Kolvo_intervalov;
Time1 = shag
Time2 = 2 * shag
Time3 = Time
% -------------------------------------------------- ----------------------%
P_nach = zeros (poryadok, poryadok);% + ones (poryadok, poryadok);
% -------------------------------------------------- ----------------------%
% Рішення рівняння Риккати методом зворотного інтегрування
P = Solve_Riccati_Method_Revers_Integr (A, B, Q, R, Time1, poryadok, P_nach);
load Solve_Riccati_Method_Revers_Integr_for_slegenie Time_R P N_str
PP = P;
for k = 1: N_str
P1 = reshape (PP (k, :), poryadok, poryadok);
for i = 1: poryadok
for j = 1: poryadok
P2 (i, j, k) = P1 (i, j);
end
end
end
size_P = size (P2)
% -------------------------------------------------- ----------------------%
% Знаходження змінних коефіцієнтів регулятора
for k = 1: N_str
K_o (k, :) =-inv (R) * B '* P2 (:,:, k);
K_pr (k, :) =-inv (R) * B ';
end
% -------------------------------------------------- ----------------------%
В
tic
% 1 інтервал
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%
Solve_Interval (P_nach, N_str, h, P2, A, B, Q, R, 0, Time1, X_0, poryadok, K_o, K_pr);
load Solve_Interval time_X X u X_o_discrete
time_X1 = time_X;
X1 = X;
u1 = u;
X_o_discrete1 = X_o_discrete;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 2 інтервал
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%
Solve_Interval (P_nach, N_str, h, P2, A, B, Q, R, Time1, Time2, X1 (:, N_str), poryadok, K_o, K_pr);
load Solve_Interval time_X X u X_o_discrete
time_X2 = time_X;
X2 = X;
u2 = u;
X_o_discrete2 = X_o_discrete;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 3 інтервал
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%
Solve_Int...