diff --git a/matlab/perfect-foresight-models/perfect_foresight_mcp_problem.m b/matlab/perfect-foresight-models/perfect_foresight_mcp_problem.m
index 40e344e1368cc539b6b3d1974b786f5e10f5ea95..eea045e1ff68ca3effbb1123fd17cad3ec0372c1 100644
--- a/matlab/perfect-foresight-models/perfect_foresight_mcp_problem.m
+++ b/matlab/perfect-foresight-models/perfect_foresight_mcp_problem.m
@@ -82,7 +82,7 @@ for it = maximum_lag+(1:T)
         [res,jacobian] = dynamic_function(YY(i_cols),exo_simul, params, steady_state,it);
         residuals(i_rows) = res(eq_index);
         if T==1 && it==maximum_lag+1
-            [rows, cols, vals] = find(jacobian(:,i_cols_0));
+            [rows, cols, vals] = find(jacobian(eq_index,i_cols_0));
             if size(jacobian, 1) == 1 % find() will return row vectors in this case
                 rows = rows';
                 cols = cols';