diff --git a/matlab/perfect-foresight-models/perfect_foresight_setup.m b/matlab/perfect-foresight-models/perfect_foresight_setup.m
index 1b502c4adb8d127b8a3329d6fee6d552849b272e..fc6a4bce754f9160b76306e991dd633f9320ce78 100644
--- a/matlab/perfect-foresight-models/perfect_foresight_setup.m
+++ b/matlab/perfect-foresight-models/perfect_foresight_setup.m
@@ -51,7 +51,7 @@ if options_.periods == 0
     error('PERFECT_FORESIGHT_SETUP: number of periods for the simulation isn''t specified')
 end
 
-if options_.periods<max([M_.det_shocks.periods])
+if ~isempty(M_.det_shocks) && options_.periods<max([M_.det_shocks.periods])
     error('PERFECT_FORESIGHT_SETUP: number of periods for the simulation is specified to be smaller than the period of the last shock')
 end