diff --git a/matlab/smoother2histval.m b/matlab/smoother2histval.m
index 84865a1ac8ae53ab5947777aaf861400bae845c8..7e90e41ef316e5b9cbb168aa4c97347a5b857bb4 100644
--- a/matlab/smoother2histval.m
+++ b/matlab/smoother2histval.m
@@ -78,6 +78,11 @@ end
 
 if post_metropolis
     tmp = fieldnames(smoothedvars.Mean);
+    if length(tmp)~=M_.endo_nbr
+        warning(['You are using smoother2histval although smoothed values have not'...
+            'been computed for all endogenous and auxiliary variables.'...
+            'The value of these variables will be set to 0.'])
+    end
     tmpexo = fieldnames(smoothedshocks.Mean);
 else
     tmp = fieldnames(smoothedvars);