From e37f9577877e120653786bec2692c58892ad8e72 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?S=C3=A9bastien=20Villemot?= <sebastien.villemot@ens.fr>
Date: Mon, 2 May 2011 12:45:00 +0200
Subject: [PATCH] More explicit error message when an endogenous with
 measurement error is not declared as observable (cherry picked from commit
 5c64b027e65513b04fba630340e2cf0f67a34caf)

---
 matlab/set_prior.m | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/matlab/set_prior.m b/matlab/set_prior.m
index 0d072dfa59..66633792c2 100644
--- a/matlab/set_prior.m
+++ b/matlab/set_prior.m
@@ -79,7 +79,11 @@ if nvn
         M_.H = zeros(nvarobs,nvarobs);
     end
     for i=1:nvn
-        estim_params_.var_endo(i,1) = strmatch(deblank(M_.endo_names(estim_params_.var_endo(i,1),:)),deblank(options_.varobs),'exact');
+        obsi_ = strmatch(deblank(M_.endo_names(estim_params_.var_endo(i,1),:)),deblank(options_.varobs),'exact');
+        if isempty(obsi_)
+            error(['The variable ' deblank(M_.endo_names(estim_params_.var_endo(i,1),:)) ' has to be declared as observable since you assume a measurement error on it.'])
+        end
+        estim_params_.var_endo(i,1) = obsi_;
     end
     xparam1 = [xparam1; estim_params_.var_endo(:,2)];
     ub = [ub; estim_params_.var_endo(:,4)]; 
-- 
GitLab