From 1914be92ea730d5cdaa4dbb7e82be550744c68ce Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Adjemian=20=28Scylla=29?=
 <stephane.adjemian@univ-lemans.fr>
Date: Fri, 2 May 2014 15:28:27 +0200
Subject: [PATCH] Check that the initial and terminal dates are in the ranges
 of the dseries objects involved in the recursive expression.

---
 matlab/utilities/dseries/from.m | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/matlab/utilities/dseries/from.m b/matlab/utilities/dseries/from.m
index 6add8244f1..2346108532 100644
--- a/matlab/utilities/dseries/from.m
+++ b/matlab/utilities/dseries/from.m
@@ -73,16 +73,23 @@ end
 % Remove duplicates.
 variables = unique(variables);
 
-% Test that all the involved variables are available dseries objects.
+% Test that all the involved variables are available dseries objects. Also check
+% that these time series are defined over the time range given by d1 and d2.
 for i=1:length(variables)
     try
         var = evalin('caller',variables{i});
     catch
-        error(['Variable ' variables{i} ' is unknown!'])
+        error(['dseries::from: Variable ' variables{i} ' is unknown!'])
     end
     if ~isdseries(var)
-        error(['Variable ' variables{i} ' is not a dseries object!'])
+        error(['dseries::from: Variable ' variables{i} ' is not a dseries object!'])
     else
+        if d1<var.dates(1)
+            error(sprintf('dseries::from: First date in variable %s is posterior to %s!\n               Check the initial date of the loop.', variables{i}, char(d1)))
+        end
+        if d2>var.dates(end)
+            error(sprintf('dseries::from: Last date in variable %s is anterior to %s!\n               Check the terminal date of the loop.', variables{i}, char(d2)))
+        end
         eval(sprintf('%s = var;',variables{i}));
     end
 end
-- 
GitLab