From 289548d85185b7b0d2e1bde7cdef6929394d3aef Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Adjemian=20=28Charybdis=29?=
 <stephane.adjemian@univ-lemans.fr>
Date: Sun, 8 Jun 2014 01:04:49 +0200
Subject: [PATCH] Allow empty dseries objects in @dseries/horzcat method. Added
 unitary test.

---
 matlab/@dseries/horzcat.m | 33 +++++++++++++++++++++++++++++++++
 1 file changed, 33 insertions(+)

diff --git a/matlab/@dseries/horzcat.m b/matlab/@dseries/horzcat.m
index 40610c3f3c..2ddf2ca756 100644
--- a/matlab/@dseries/horzcat.m
+++ b/matlab/@dseries/horzcat.m
@@ -51,6 +51,14 @@ end
 
 function a = concatenate(b,c)
     [n,message] = common_strings_in_cell_arrays(b.name,c.name);
+    if isempty(b)
+        a = c;
+        return
+    end
+    if isempty(c)
+        a = b;
+        return
+    end
     if n
         error(['dseries::horzcat: I cannot concatenate dseries objects with common variable names (' message ')!'])
     end
@@ -289,3 +297,28 @@ function a = concatenate(b,c)
 %$
 %$ T = t;
 %@eof:6
+
+%@test:7
+%$ % Define X
+%$ X = randn(30,2);
+%$
+%$ % Instantiate two time series objects.
+%$ ts1 = dseries();
+%$ ts2 = dseries(randn(30,2),'1950Q2');
+%$
+%$ % Call the tested method.
+%$ try
+%$   ts3 = [ts1,ts2];
+%$   t = 1;
+%$ catch
+%$   t = 0;
+%$ end
+%$
+%$ if t(1)
+%$   t(2) = dyn_assert(ts3.freq,4);
+%$   t(3) = dyn_assert(ts3.data,X);
+%$   t(4) = dyn_assert(isequal(ts3.dates(1),dates('1950Q2')),1);
+%$ end
+%$
+%$ T = t;
+%@eof:7
-- 
GitLab