diff --git a/matlab/dynare_estimation_init.m b/matlab/dynare_estimation_init.m
index 90189e7c85fafa86d1bce1142b71e9d5762391d8..6cb9f4d446db368694c0547050ae04dab1f1c992 100644
--- a/matlab/dynare_estimation_init.m
+++ b/matlab/dynare_estimation_init.m
@@ -70,7 +70,7 @@ end
 % Check that a variable is not declared as observed more than once.
 if ~isequal(options_.varobs,unique(options_.varobs))
     for i = 1:options_.number_of_observed_variables
-        if length(strmatch(options_.varobs{i},varobs))>1
+        if length(strmatch(options_.varobs{i},options_.varobs))>1
             error(['A variable cannot be declared as observed more than once (' options_.varobs{i} ')!'])
         end
     end