diff --git a/matlab/ep/extended_path.m b/matlab/ep/extended_path.m
index 99b5925c86ee6e62f4745d6332741b0f172c1f4a..92f5623f431154d54b8895233aaa6b8d11df62cb 100644
--- a/matlab/ep/extended_path.m
+++ b/matlab/ep/extended_path.m
@@ -116,8 +116,8 @@ if options_.ep.stochastic.status
         end
         if options_.ep.stochastic.order*M_.exo_nbr>1
             for i=1:options_.ep.stochastic.order*M_.exo_nbr
-                rr(k) = {r};
-                ww(k) = {w};
+                rr(i) = {r};
+                ww(i) = {w};
             end
             rrr = cartesian_product_of_sets(rr{:});
             www = cartesian_product_of_sets(ww{:});