%This repacks all of our data from coefficients matricies back into the %vector x which can be fed into the optimizer. %%function [x]= packing(A ,Ahat, B, Bhat, D, theta,r); function [X]= packing(A ,Ahat, B, Bhat, D, theta,r); s=length(A); aa=[]; for i=2:s; for j=1:i-1; aa=[aa,A(i,j)]; end end aa=aa(:); ah=Ahat(2:end,:); ah=ah(:); bb=B(:); bh=Bhat(:); dd=D(:,1:end-1); dd=dd(:); th=theta(1:end-1); th=th(:); X=[aa;ah;bb;bh;dd;th;r]; X=X' end