%%%Unpacking Explicit Type 2 MSRK%%%%%% %&& We are taking our coeficient vector X which is being fed through %%% the optimizer and unpacking the pieces back into the original form %%% A is explicit and has (S^2-S)/2 unknowns, with 0s padding the first row %%% Ahat is (S-1)x(k-1) unknowns, with 0s padding the first row %%% B is 1 x S %%% Bhat is 1x(k-1) %%% D is (S-1)x k unknowns, with [00....1] for the first row %%% Theta is 1 x k function [A ,Ahat, B, Bhat, D, Theta] = unpackexplicitT2(x, s, k) count1= (s^2-s)/2; count2= count1 + (s-1)*(k-1); count3= count2+s; count4= count3 + (k-1); count5 = count4 +(s-1)*(k-1); count6= count5+k-1; A=zeros(s-1,s); count=1; for i = 1:s-1 A(i,1:i)=x(count:count+i-1); count= count+i; end A=[zeros(1,s);A]; Ahat=zeros(1,k-1); Ahat= [Ahat; reshape(x(count1+1:count2),s-1,k-1)]; B= x(count2+1:count3); Bhat= x(count3+1:count4); D=reshape(x(count4+1:count5),s-1,k-1); D(:,end+1) = 1- sum(D,2); Theta = x(count5+1:count6); Theta(end+1)= 1-sum(Theta); %%Aa= [zeros(k-1,s+k-1);Ahat,A]; %%Bb= [Bhat, B]; %%Dd= [eye(k);D]; end