I encounter some problems when using CVX to solve semidefinite programming problems, and I always fail to obtain the desired solution.

clear, clc;
A = [0 1 0; 0 0 1; -0.2 0.2 1.1];
B = [0; 0; 1];
Q = eye(3);
u = rand(1,14);
x0 = rand(3, 1);
% 生成响应
t=14;x=zeros(3,t);x(:,1)=x0;
for i=1:t
x(:,i+1)=Ax(:,i)+Bu(1,i)
end
x_i0=x(:,1:14);
x_i1=x(:,2:15);
U_i=u;
% 使用CVX求解优化问题
Q = eye(3);
%生成随机半正定矩阵R
T = randn(3);
R = T* T’;
[V, D] = eig(R); % 对A进行特征值分解
D(D < 0) = 0; % 将负特征值设为零,确保半正定性
R = V * D * V’; % 重构半正定矩阵
chol(R);
%求解x_i0的左伪逆
x_R=(x_i0’)inv(x_i0(x_i0’));
% %CVX工具箱
cvx_begin sdp
cvx_solver sedumi
variable P(3, 3) symmetric
minimize trace(QP)
subject to
[P-R,(x_i1
(x_RP));(x_i1(x_RP))',P] >= 0; % 使用 >= 0 来表示半正定约束
cvx_end
%求解K
K =U_i
(x_R*P)*pinv(P);

What problems do you encounter, and how does it differ from the “desired” solution?

Thank you for your concern, this issue was resolved for me.