%compute the steady state of RBC Model 
function[ys,check]=nonline_stoc_5_steadystate(ys,exe)
global M_
 
%% DO NOT CHANGE THIS PART.
%%
%% Here we load the values of the deep parameters in a loop.
%%
NumberOfParameters = M_.param_nbr;                            % Number of deep parameters.
for i = 1:NumberOfParameters                                  % Loop...
  paramname = deblank(M_.param_names(i,:));                   %    Get the name of parameter i. 
  eval([ paramname ' = M_.params(' int2str(i) ');']);         %    Get the value of parameter i.
end                                                           % End of the loop.  
check = 0;
%%


%% THIS BLOCK IS MODEL SPECIFIC.
%%
%% Here the user has to define the steady state.
%%
 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

Y=1;
C=Y;
uc=C^(-gama);
Lambda=pbeta*uc/uc; 
S_1=Lambda;
R=1/Lambda; 
R1=R;
Omega=@(phi,N) sigmaa+(1-sigmaa)*theta*phi; 

a=@(phi,N) S_1*R1*Omega(phi,N);
b=@(phi,N) (1-x)*Lambda*Omega(phi,N)*(phi*N+Y);
M1=@(phi,N) phi-(b(phi,N)+N*a(phi,N))/(N*((1-x)*a(phi,N)+theta));


c=@(phi,N) (1-sigmaa)*((1-x)*Y-R*N*((1-x)*phi-1))+sigmaa*Nn;
d=(1-sigmaa)*(1-x);
M2=@(phi,N) N-c(phi,N)/(1-d*phi);
 
%%
MN1=@(phi,N) [M1(phi,N),M2(phi,N)];

options=optimset('TolFun',1e-12);
[V,fval]=fsolve(@(x) MN1(x(1),x(2)) ,[1,100],options)
%%

phi=V(1);
N=V(2);
Omega=sigmaa+(1-sigmaa)*theta*phi; 
a=Lambda*Omega*R;

b=(1-x)*Lambda*Omega*(phi*N+Y);
%phi=(b+N*a)/(N*((1-x)*a+theta));


c=(1-sigmaa)*((1-x)*Y-R*N*((1-x)*phi-1))+sigmaa*Nn;


%N=c/(1-d*phi);

Q=phi*N;
xd=((1-x)*phi-1);
D=xd*N;
mun=b/Q;
mud=mun-a;
%********************

%  ***********************
 



%% END OF THE MODEL SPECIFIC BLOCK.


%% DO NOT CHANGE THIS PART.
%%
%% Here we define the steady state vZNues of the endogenous variables of
%% the model.
%%
NumberOfEndogenousVariables = M_.endo_nbr;                    % Number of endogenous variables.
ys = zeros(NumberOfEndogenousVariables,1);                    % Initialization of ys (steady state).
for i = 1:NumberOfEndogenousVariables                         % Loop...
  varname = deblank(M_.endo_names(i,:));                      %    Get the name of endogenous variable i.                     
  eval(['ys(' int2str(i) ') = ' varname ';']);                %    Get the steady state vZNue of this variable.
end                                                           % End of the loop.
%%