From 998ce16b62f9e96601b29ca7fafa8cf7629bb2a4 Mon Sep 17 00:00:00 2001
From: adjemian <adjemian@ac1d8469-bf42-47a9-8791-bf33cf982152>
Date: Tue, 20 Dec 2005 20:11:07 +0000
Subject: [PATCH] Correction of a bug in metropolis.m related to option
 load_mh_file with nblck=1.

git-svn-id: https://www.dynare.org/svn/dynare/dynare_v3@564 ac1d8469-bf42-47a9-8791-bf33cf982152
---
 matlab/EvalWelfare.m | 3 ++-
 matlab/metropolis.m  | 9 ++++++++-
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/matlab/EvalWelfare.m b/matlab/EvalWelfare.m
index fabb40d9a4..d0a4e72f26 100644
--- a/matlab/EvalWelfare.m
+++ b/matlab/EvalWelfare.m
@@ -101,4 +101,5 @@ if pltOpt
   box on
   xlabel('Welfare')
   ylabel('Posterior density')
-end
\ No newline at end of file
+end
+options_.order = 1;
\ No newline at end of file
diff --git a/matlab/metropolis.m b/matlab/metropolis.m
index 9280822ffc..11eb229f2b 100644
--- a/matlab/metropolis.m
+++ b/matlab/metropolis.m
@@ -118,9 +118,16 @@ function metropolis(xparam1,vv,gend,data,rawdata,mh_bounds)
       if nblck>1
 	files = eval(['dir(''' fname_ '_mh*_blck*.mat'');']);
 	bfiles = eval(['dir(''' fname_ '_mh0_blck*.mat'');']);
+	lfile = length(files)/length(bfiles)-1;
       else
 	files = eval(['dir(''' fname_ '_mh*.mat'');']);
 	bfiles = 1;
+	ifiles = eval(['dir(''' fname_ '_MhInitialization.mat'');']);
+	if isempty(ifiles)
+	  lfile = length(files)-1;
+	else
+	  lfile = length(files)-2;
+	end
       end
       if ~length(files)
 	error('MH: FAILURE :: there is no MH file to load here!')    
@@ -133,7 +140,7 @@ function metropolis(xparam1,vv,gend,data,rawdata,mh_bounds)
 	nblck = past_number_of_blocks;
 	options_.mh_nblck = nblck;
       end
-      lfile = length(files)/nblck-1;
+      %lfile = length(files)/nblck-1;
       if nblck == 1
 	instr = [fname_ '_mh' int2str(lfile)];
 	eval(['load ' instr]);
-- 
GitLab