diff --git a/matlab/dr1.m b/matlab/dr1.m
index fd890ff5e28cc2cc88a8a3d640a0dc3a68d8f737..fefc49c4b91135c44ddb87f6f866f97f0d546322 100644
--- a/matlab/dr1.m
+++ b/matlab/dr1.m
@@ -177,7 +177,7 @@ b11 = b(1:nstatic,nstatic+1:end);
 b2 = b(nstatic+1:end,nstatic+1:end);
 nz = nnz(iy_);
 if exo_nbr
-  fu = aa(:,nz+1:end);
+  fu = aa(:,nz+[1:exo_nbr]);
 end
 clear aa;
 
diff --git a/matlab/forecast.m b/matlab/forecast.m
index f07ee6364a6e9bb5e6df6279ad4bf1bb88776b3e..60c3e5a6786365a521935246e671f2585bdec5ee 100644
--- a/matlab/forecast.m
+++ b/matlab/forecast.m
@@ -19,10 +19,12 @@ function forecast(var_list)
   if exo_det_nbr == 0
     [yf,var_yf] = forcst(dr_,y0,options_.periods,var_list);
   else
-    ex = zeros(options_.periods,exo_nbr);
     if options_.periods > size(ex_det_,1)
+      ex = zeros(options_.periods,exo_nbr);
       ex_det_ = [ ex_det_; repmat(exe_det_',options_.periods- ...
 				  size(ex_det_,1),1)];
+    elseif options_.periods < size(ex_det_,1)
+      ex = zeros(size(ex_det_,1),exo_nbr); 
     end
     [yf,int_width] = simultxdet(y0,dr_,ex,ex_det_,options_.order, ...
 				  var_list);