function [beta,PROBLEM] = getcoef_2(X,B0,H,Sigma,N,L,ex,betaols,MAXTRYS)
iSigma=invpd(Sigma);
SX=kron(iSigma,X'*X);
V=invpd(H+SX);

M=V*(H*B0+SX*betaols);

cvstar=cholx(V);

%beta=M+(randn(1,N*(N*L+ex))*cvstar)';

PROBLEM=0;
check=-1;
tryx=1;
   while check<0 && tryx<MAXTRYS
beta=M+(randn(1,N*(N*L+ex))*cvstar)';

CH=stability(beta,N,L,ex);
    if CH==0
    check=10;
    else
      tryx=tryx+1;
    end
   end
   if CH>0
       PROBLEM=1;
   end
   


end