% get_ex() - get estimated values of x
%
function ex = get_ex()

global states;
global N;
global L;
global K;
global path_index;
global perm_index;
global combos;
global perms;

t = states(1,:);

if( K == 1)

  ex = reshape( t(path_index), N, L);

else % K > 1

  ex = zeros(N,L*K);
  ex1 = zeros(K,N);

  for el = 1:L

    for j = 1:N
      combo = combos(:,path_index(el,j));
      ii = perms(:,perm_index(el,j));
      ex1(:,j) = t(combo(ii))';
    end

    ex(:,(el-1)*K+[1:K]) = ex1';

  end

end
