diff --git a/matlab/backward/backward_model_irf.m b/matlab/backward/backward_model_irf.m
index 37952e6138d244d2f10ab6ced7070e6573f0092b..a90ffeb33d1455ba5529f79a2e29a4b696b747f3 100644
--- a/matlab/backward/backward_model_irf.m
+++ b/matlab/backward/backward_model_irf.m
@@ -99,7 +99,7 @@ end
 
 % Check fourth argument. If empty return the paths for all the endogenous variables.
 if isempty(listofvariables)
-    listofvariables = M_.endo_names;
+    listofvariables = M_.endo_names(1:M_.orig_endo_nbr);
 end
 if ~iscell(listofvariables)
     error('Fourth input argument has to be a cell of row char arrays or an empty object.')