function [P,q,c]=XtoP(x,n) %%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % Defolding a state vector into the Riccati matrices % % %%%%%%%%%%%%%%%%%%%%%%%%%%%% k=0; for i=1:n for j=1:i k=k+1; P(i,j)=x(k); P(j,i)=x(k); % P beeing symmetric end end for i=1:n k=k+1; q(i,1)=x(k); end c=x(k+1); %%%%%%%%%%%%%% end of file %%%%%