diff --git a/doc/dynare.texi b/doc/dynare.texi
index a7473fd90ab64595e7df939ff062dcbb79629668..5b16f457602b444600df7e32c81c76d06c83def5 100644
--- a/doc/dynare.texi
+++ b/doc/dynare.texi
@@ -2070,9 +2070,10 @@ It is possible to specify shocks which last several periods and which can
 vary over time. The @code{periods} keyword accepts a list of
 several dates or date ranges, which must be matched by as many shock values
 in the @code{values} keyword. Note that a range in the
-@code{periods} keyword must be matched by only one value in the
-@code{values} keyword: this syntax means that the exogenous variable
-will have a constant value over the range.
+@code{periods} keyword can be matched by only one value in the
+@code{values} keyword. If @code{values} represents a scalar, the same
+value applies to the whole range. If @code{values} represents a vector,
+it must have as many elements as there are periods in the range.
 
 Note that shock values are not restricted to numerical constants:
 arbitrary expressions are also allowed, but you have to enclose them
@@ -2097,6 +2098,18 @@ values (1+p) (exp(z));
 end;
 @end example
 
+A second example with a vector of values:
+
+@example
+xx = [1.2; 1.3; 1];
+
+shocks;
+var e;
+periods 1:3;
+values (xx);
+end;
+@end example
+
 @customhead{In stochastic context}
 
 For stochastic simulations, the @code{shocks} block specifies the non
diff --git a/matlab/set_shocks.m b/matlab/set_shocks.m
index 410d3b5f43fdfc7377415680003ec97213daf74a..d6fead20aeb53607d3d4e7f4cd8f36f9fc651285 100644
--- a/matlab/set_shocks.m
+++ b/matlab/set_shocks.m
@@ -48,11 +48,19 @@ end
 
 switch flag
   case 0
-    oo_.exo_simul(k,ivar) = repmat(values,length(k),1);
+    if size(values,1) == 1
+        oo_.exo_simul(k,ivar) = repmat(values,length(k),1);
+    else
+        oo_.exo_simul(k,ivar) = values;
+    end
   case 1
     oo_.exo_simul(k,ivar) = oo_.exo_simul(k,ivar).*values;
   case 2
-    oo_.exo_det_simul(k,ivar) = repmat(values,length(k),1);
+    if size(values,1) == 1
+        oo_.exo_det_simul(k,ivar) = repmat(values,length(k),1);
+    else
+        oo_.exo_det_simul(k,ivar) = values;
+    end
   case 3
     oo_.exo_det_simul(k,ivar) = oo_.exo_det_simul(k,ivar).*values;
 end
diff --git a/tests/ramst_vec.mod b/tests/ramst_vec.mod
new file mode 100644
index 0000000000000000000000000000000000000000..6085a1193d54202b81e33d65225abdfb4579e06f
--- /dev/null
+++ b/tests/ramst_vec.mod
@@ -0,0 +1,38 @@
+var c k;
+varexo x;
+
+parameters alph gam delt bet aa;
+alph=0.5;
+gam=0.5;
+delt=0.02;
+bet=0.05;
+aa=0.5;
+
+
+model;
+c + k - aa*x*k(-1)^alph - (1-delt)*k(-1);
+c^(-gam) - (1+bet)^(-1)*(aa*alph*x(+1)*k^(alph-1) + 1 - delt)*c(+1)^(-gam);
+end;
+
+initval;
+x = 1;
+k = ((delt+bet)/(1.0*aa*alph))^(1/(alph-1));
+c = aa*k^alph-delt*k;
+end;
+
+steady;
+
+check;
+
+a=[1.2; 1.1];
+
+shocks;
+var x;
+periods 1:2;
+values (a);
+end;
+
+simul(periods=200);
+
+rplot c;
+rplot k;