diff --git a/matlab/set_prior.m b/matlab/set_prior.m index c661c8620..e701b2c10 100644 --- a/matlab/set_prior.m +++ b/matlab/set_prior.m @@ -221,4 +221,38 @@ function [xparam1, estim_params_, bayestopt_, lb, ub, M_]=set_prior(estim_params end k = find(isnan(xparam1)); - xparam1(k) = bayestopt_.p1(k); \ No newline at end of file + xparam1(k) = bayestopt_.p1(k); + + CheckPath('prior'); + + if exist([ M_.dname '/prior/definition.mat']) + bayestopt_old = load([M_.dname '/prior/definition.mat'],'bayestopt_'); + prior_has_changed = 0; + if any(bayestopt_.p1-bayestopt_old.p1) + prior_has_changed = 1; + end + if any(bayestopt_.p2-bayestopt_old.p2) + prior_has_changed = 1; + end + if any(bayestopt_.p3-bayestopt_old.p3) + prior_has_changed = 1; + end + if any(bayestopt_.p4-bayestopt_old.p4) + prior_has_changed = 1; + end + if any(bayestopt_.p5-bayestopt_old.p5) + prior_has_changed = 1; + end + if any(bayestopt_.p6-bayestopt_old.p6) + prior_has_changed = 1; + end + if any(bayestopt_.p7-bayestopt_old.p7) + prior_has_changed = 1; + end + if prior_has_changed + delete([M_.dname '/prior/definition.mat']); + save([M_.dname '/prior/definition.mat'],'bayestopt_'); + end + else + save([M_.dname '/prior/definition.mat'],'bayestopt_'); + end \ No newline at end of file