diff --git a/matlab/AIM_first_order_solver.m b/matlab/AIM_first_order_solver.m
index 5ac8129414f2a75503cdfa8be8dd084995868272..026c2619eeb9c46789208786f495a160ff6dbbcb 100644
--- a/matlab/AIM_first_order_solver.m
+++ b/matlab/AIM_first_order_solver.m
@@ -77,8 +77,7 @@ if aimcode ~=1
     info(2) = 1.0e+8;
     return
 end
-A = kalman_transition_matrix(dr,M.nstatic+(1:M.nspred), 1:M.nspred,...
-                             M.exo_nbr);
+A = kalman_transition_matrix(dr,M.nstatic+(1:M.nspred), 1:M.nspred);
 dr.eigval = eig(A);
 disp(dr.eigval)
 nd = size(dr.kstate,1);
diff --git a/matlab/DsgeSmoother.m b/matlab/DsgeSmoother.m
index 3075e7a0b32e1a3c3635b5a3b36ef00a729afcbb..f2a70113488e965b4059dd8ea4a837a33d5912cd 100644
--- a/matlab/DsgeSmoother.m
+++ b/matlab/DsgeSmoother.m
@@ -386,7 +386,7 @@ else
             end
         end
         if isoccbin==0
-            [A,B] = kalman_transition_matrix(oo_.dr,(1:M_.endo_nbr)',ic,M_.exo_nbr);
+            [A,B] = kalman_transition_matrix(oo_.dr,(1:M_.endo_nbr)',ic);
         else
             opts_simul = options_.occbin.simul;
         end
@@ -540,7 +540,7 @@ else
         end
     else
         % reconstruct smoother
-        [A,B] = kalman_transition_matrix(oo_.dr,(1:M_.endo_nbr)',ic,M_.exo_nbr);
+        [A,B] = kalman_transition_matrix(oo_.dr,(1:M_.endo_nbr)',ic);
         iT = pinv(T);
         Tstar = A(~ismember(1:M_.endo_nbr,oo_.dr.restrict_var_list),oo_.dr.restrict_var_list);
         Rstar = B(~ismember(1:M_.endo_nbr,oo_.dr.restrict_var_list),:);
diff --git a/matlab/UnivariateSpectralDensity.m b/matlab/UnivariateSpectralDensity.m
index 31ce57f69c22e0cdbd55772780bb6d2d120ea2f3..d829ba3f30d94207dceac2cc4b2bb58cfdc13b60 100644
--- a/matlab/UnivariateSpectralDensity.m
+++ b/matlab/UnivariateSpectralDensity.m
@@ -92,7 +92,7 @@ for i=M_.maximum_lag:-1:2
     i0 = i1;
 end
 
-[A,B] = kalman_transition_matrix(oo_.dr,ikx',1:nx,M_.exo_nbr);
+[A,B] = kalman_transition_matrix(oo_.dr,ikx',1:nx);
 [vx, u] =  lyapunov_symm(A,B*M_.Sigma_e*B',options_.lyapunov_fixed_point_tol,options_.qz_criterium,options_.lyapunov_complex_threshold,[],options_.debug);
 iky = iv(ivar);
 if ~isempty(u)
diff --git a/matlab/conditional_variance_decomposition.m b/matlab/conditional_variance_decomposition.m
index 088a62ddc8c63eb90063afd2efad09fa52b87221..c9d92e406a4562e8c1fbd937f795fef6aab5b593 100644
--- a/matlab/conditional_variance_decomposition.m
+++ b/matlab/conditional_variance_decomposition.m
@@ -41,7 +41,7 @@ if any(Steps <= 0)
            'positive'])
 end
 
-[transition_matrix, impulse_matrix] = kalman_transition_matrix(dr,(1:M_.endo_nbr)',M_.nstatic+(1:M_.nspred)',M_.exo_nbr);
+[transition_matrix, impulse_matrix] = kalman_transition_matrix(dr,(1:M_.endo_nbr)',M_.nstatic+(1:M_.nspred)');
 
 number_of_state_innovations = M_.exo_nbr;
 number_of_state_equations = M_.endo_nbr;
diff --git a/matlab/dynare_resolve.m b/matlab/dynare_resolve.m
index aca22c68a5d00672f0fefab9769747b5f9cf9d84..b3bf6ed1a5cb69f06cf09dacffd13f49b68fd306 100644
--- a/matlab/dynare_resolve.m
+++ b/matlab/dynare_resolve.m
@@ -61,9 +61,9 @@ switch nargin
 end
 
 if nargout==1
-    A = kalman_transition_matrix(oo_.dr,iv,ic,M_.exo_nbr);
+    A = kalman_transition_matrix(oo_.dr,iv,ic);
     return
 end
 
-[A,B] = kalman_transition_matrix(oo_.dr,iv,ic,M_.exo_nbr);
+[A,B] = kalman_transition_matrix(oo_.dr,iv,ic);
 ys = oo_.dr.ys;
diff --git a/matlab/forcst.m b/matlab/forcst.m
index 874b8ea69026440281741dd55f9ad2baa6e89f8b..0d47fc7a9db72c74e5b02d0ab5d110a756ca82d0 100644
--- a/matlab/forcst.m
+++ b/matlab/forcst.m
@@ -46,7 +46,7 @@ nspred = M_.nspred;
 nc = size(dr.ghx,2);
 endo_nbr = M_.endo_nbr;
 inv_order_var = dr.inv_order_var;
-[A,B] = kalman_transition_matrix(dr,nstatic+(1:nspred),1:nc,M_.exo_nbr);
+[A,B] = kalman_transition_matrix(dr,nstatic+(1:nspred),1:nc);
 
 if isempty(var_list)
     var_list = M_.endo_names(1:M_.orig_endo_nbr);
diff --git a/matlab/get_variance_of_endogenous_variables.m b/matlab/get_variance_of_endogenous_variables.m
index 3e37bb6f4e1b6c5629614aa891f9175b12c5dfae..85585cf85d2d1f0aa47fd42477b3ca9699c3bade 100644
--- a/matlab/get_variance_of_endogenous_variables.m
+++ b/matlab/get_variance_of_endogenous_variables.m
@@ -43,7 +43,7 @@ ghu = dr.ghu(i_var,:);
 nc = size(ghx,2);
 n = length(i_var);
 
-[A,B] = kalman_transition_matrix(dr,nstatic+(1:nspred),1:nc,M_.exo_nbr);
+[A,B] = kalman_transition_matrix(dr,nstatic+(1:nspred),1:nc);
 
 [vx,u] = lyapunov_symm(A,B*Sigma_e*B',options_.lyapunov_fixed_point_tol,options_.qz_criterium,options_.lyapunov_complex_threshold, [], options_.debug);
 
diff --git a/matlab/gsa/map_ident_.m b/matlab/gsa/map_ident_.m
index a0f353d23ac7461dd31e0b0910747642a246d893..73eb02fbc94ae44e553a214ed17bb2f61081454a 100644
--- a/matlab/gsa/map_ident_.m
+++ b/matlab/gsa/map_ident_.m
@@ -129,7 +129,7 @@ if opt_gsa.load_ident_files==0
 
     dr.ghx = T(:, [1:(nc1-M_.exo_nbr)],1);
     dr.ghu = T(:, [(nc1-M_.exo_nbr+1):end], 1);
-    [Aa,Bb] = kalman_transition_matrix(dr,iv,ic,M_.exo_nbr);
+    [Aa,Bb] = kalman_transition_matrix(dr,iv,ic);
     %     bayestopt_.restrict_var_list, ...
     %     bayestopt_.restrict_columns, ...
     %     bayestopt_.restrict_aux, M_.exo_nbr);
@@ -142,7 +142,7 @@ if opt_gsa.load_ident_files==0
     for j=2:length(istable)
         dr.ghx = T(:, [1:(nc1-M_.exo_nbr)],j);
         dr.ghu = T(:, [(nc1-M_.exo_nbr+1):end], j);
-        [Aa,Bb] = kalman_transition_matrix(dr, iv, ic, M_.exo_nbr);
+        [Aa,Bb] = kalman_transition_matrix(dr, iv, ic);
         %       bayestopt_.restrict_var_list, ...
         %       bayestopt_.restrict_columns, ...
         %       bayestopt_.restrict_aux, M_.exo_nbr);
diff --git a/matlab/kalman_transition_matrix.m b/matlab/kalman_transition_matrix.m
index 427e3aa7e83d7d071a7704cc1f186a1ae91fa38b..62ed7ef86dd42f5e5de11319689825496d4e1ec8 100644
--- a/matlab/kalman_transition_matrix.m
+++ b/matlab/kalman_transition_matrix.m
@@ -1,12 +1,11 @@
-function [A,B] = kalman_transition_matrix(dr,iv,ic,exo_nbr)
-%function [A,B] = kalman_transition_matrix(dr,iv,ic,exo_nbr)
+function [A,B] = kalman_transition_matrix(dr,iv,ic)
+%function [A,B] = kalman_transition_matrix(dr,iv,ic)
 % Builds the transition equation of the state space representation out of ghx and ghu for Kalman filter
 %
 % INPUTS
 %    dr:      structure of decisions rules for stochastic simulations
 %    iv:      selected variables
 %    ic:      state variables position in the transition matrix columns
-%    exo_nbr: number of exogenous variables
 %
 % OUTPUTS
 %    A:       matrix of predetermined variables effects in linear solution (ghx)
diff --git a/matlab/moments/th_autocovariances.m b/matlab/moments/th_autocovariances.m
index 31fc2a25ff2100002be48f6d38c94985ba9d4e5b..dc002666b31de09749e783e6867d5beb35ea7574 100644
--- a/matlab/moments/th_autocovariances.m
+++ b/matlab/moments/th_autocovariances.m
@@ -96,7 +96,7 @@ ghu_states_only = zeros(M_.nspred,M_.exo_nbr);
 ghu_states_only(1:M_.nspred,:) = ghu(index_states,:); %get shock impact on states only
 
 % state space representation for state variables only
-[A,B] = kalman_transition_matrix(dr,index_states,1:M_.nspred,M_.exo_nbr);
+[A,B] = kalman_transition_matrix(dr,index_states,1:M_.nspred);
 % Compute stationary variables for unfiltered moments (filtering will remove unit roots)
 if options_.hp_filter ~= 0 || options_.bandpass.indicator
     % By construction, all variables are stationary when filtered
diff --git a/matlab/non_linear_dsge_likelihood.m b/matlab/non_linear_dsge_likelihood.m
index 8455944a701ed5e44e046cad8d9cd20a121ccac4..58dc3ee293933f095401065cb01124cd9a3cbea2 100644
--- a/matlab/non_linear_dsge_likelihood.m
+++ b/matlab/non_linear_dsge_likelihood.m
@@ -153,7 +153,7 @@ end
 switch DynareOptions.particle.initialization
   case 1% Initial state vector covariance is the ergodic variance associated to the first order Taylor-approximation of the model.
     StateVectorMean = ReducedForm.constant(mf0);
-    [A,B] = kalman_transition_matrix(dr,dr.restrict_var_list,dr.restrict_columns,Model.exo_nbr);
+    [A,B] = kalman_transition_matrix(dr,dr.restrict_var_list,dr.restrict_columns);
     StateVectorVariance = lyapunov_symm(A, B*Q*B', DynareOptions.lyapunov_fixed_point_tol, ...
                                         DynareOptions.qz_criterium, DynareOptions.lyapunov_complex_threshold, [], DynareOptions.debug);
     StateVectorVariance = StateVectorVariance(mf0,mf0);
diff --git a/matlab/nonlinear-filters/solve_model_for_online_filter.m b/matlab/nonlinear-filters/solve_model_for_online_filter.m
index 92cbf4c74042ee8d729a069e6fb7241796d58953..ae17f477f7f4eef963d1508bcb9f6e7e9a4cc41e 100644
--- a/matlab/nonlinear-filters/solve_model_for_online_filter.m
+++ b/matlab/nonlinear-filters/solve_model_for_online_filter.m
@@ -187,7 +187,7 @@ if setinitialcondition
     switch DynareOptions.particle.initialization
       case 1% Initial state vector covariance is the ergodic variance associated to the first order Taylor-approximation of the model.
         StateVectorMean = ReducedForm.state_variables_steady_state;%.constant(mf0);
-        [A,B] = kalman_transition_matrix(dr,dr.restrict_var_list,dr.restrict_columns,Model.exo_nbr);
+        [A,B] = kalman_transition_matrix(dr,dr.restrict_var_list,dr.restrict_columns);
         StateVectorVariance2 = lyapunov_symm(ReducedForm.ghx(mf0,:),ReducedForm.ghu(mf0,:)*ReducedForm.Q*ReducedForm.ghu(mf0,:)',DynareOptions.lyapunov_fixed_point_tol,DynareOptions.qz_criterium,DynareOptions.lyapunov_complex_threshold);
         StateVectorVariance = lyapunov_symm(A, B*ReducedForm.Q*B', DynareOptions.lyapunov_fixed_point_tol, ...
                                         DynareOptions.qz_criterium, DynareOptions.lyapunov_complex_threshold, [], DynareOptions.debug);
diff --git a/matlab/simultxdet.m b/matlab/simultxdet.m
index 2da4c02dfebb3c2fbf35cde65b978da964ade24e..ba449664beec0b456c60f2d4f4f0c4d5ee94b920 100644
--- a/matlab/simultxdet.m
+++ b/matlab/simultxdet.m
@@ -121,7 +121,7 @@ elseif iorder == 2
     end
 end
 
-[A,B] = kalman_transition_matrix(dr,nstatic+(1:nspred),1:nc,M_.exo_nbr);
+[A,B] = kalman_transition_matrix(dr,nstatic+(1:nspred),1:nc);
 
 inv_order_var = dr.inv_order_var;
 ghx1 = dr.ghx(inv_order_var(ivar),:);
diff --git a/matlab/stochastic_solvers.m b/matlab/stochastic_solvers.m
index b30da096ccb5f3e3e0b8177e12fd211b965eae90..6b0c4a55e8842c27bb819f555d37941ea65ddb00 100644
--- a/matlab/stochastic_solvers.m
+++ b/matlab/stochastic_solvers.m
@@ -223,7 +223,7 @@ if M_.maximum_endo_lead == 0
         if M_.exo_nbr
             dr.ghu =  -b\jacobia_(:,nz+1:end);
         end
-        dr.eigval = eig(kalman_transition_matrix(dr,nstatic+(1:nspred),1:nspred,M_.exo_nbr));
+        dr.eigval = eig(kalman_transition_matrix(dr,nstatic+(1:nspred),1:nspred));
         dr.full_rank = 1;
         dr.edim = nnz(abs(dr.eigval) > options_.qz_criterium);
         dr.sdim = nd-dr.edim;