diff --git a/matlab/backward/backward_model_irf.m b/matlab/backward/backward_model_irf.m
index 7cff3c2922e25e27a475d75de506bdb7473770c1..7760a2ffd7d42e85eb5cdfd90a32052b32e1d9ee 100644
--- a/matlab/backward/backward_model_irf.m
+++ b/matlab/backward/backward_model_irf.m
@@ -19,7 +19,7 @@ function [deviations, baseline, irfs] = backward_model_irf(initialcondition, inn
 %   argument.
 % - If second argument is not empty, periods must not be greater than innovationbaseline.nobs.
 
-% Copyright (C) 2017-2018 Dynare Team
+% Copyright (C) 2017-2020 Dynare Team
 %
 % This file is part of Dynare.
 %
@@ -97,6 +97,14 @@ else
     end
 end
 
+% Check fourth argument. If empty return the paths for all the endogenous variables.
+if isempty(listofvariables)
+    listofvariables = M_.endo_names;
+end
+if ~iscell(listofvariables)
+    error('Fourth input argument has to be a cell of row char arrays or an empty object.')
+end
+
 % Set default initial conditions for the innovations.
 for i=1:M_.exo_nbr
     if ~ismember(M_.exo_names{i}, initialcondition.name)