Commit 78e9194f authored by Stéphane Adjemian's avatar Stéphane Adjemian
Browse files

Fixed horzcat overloaded method (dynSeries).

parent 325b06de
......@@ -77,13 +77,13 @@ end
%$ B = [transpose(1:10),2*transpose(1:10)];
%$
%$ % Define names
%$ A_name = char('A1','A2');
%$ B_name = char('B1','B2');
%$ A_name = {'A1';'A2'};
%$ B_name = {'B1';'B2'};
%$
%$ % Define expected results.
%$ e.time = [transpose(1:10), ones(10,1)];
%$ e.time = dynDate(1);
%$ e.freq = 1;
%$ e.name = char('A1','A2','B1','B2');
%$ e.name = {'A1';'A2';'B1';'B2'};
%$ e.data = [A,B];
%$
%$ % Instantiate two time series objects.
......@@ -95,7 +95,7 @@ end
%$
%$ % Check the results.
%$
%$ t(1) = dyn_assert(ts3.Time.time,e.time);
%$ t(1) = dyn_assert(ts3.init,e.time);
%$ t(2) = dyn_assert(ts3.freq,e.freq);
%$ t(3) = dyn_assert(ts3.data,e.data);
%$ t(4) = dyn_assert(ts3.name,e.name);
......@@ -108,8 +108,8 @@ end
%$ B = [transpose(5:12),2*transpose(5:12)];
%$
%$ % Define names
%$ A_name = char('A1','A2');
%$ B_name = char('B1','B2');
%$ A_name = {'A1';'A2'};
%$ B_name = {'B1';'B2'};
%$
%$ % Define initial date
%$ A_init = 2001;
......@@ -117,8 +117,9 @@ end
%$
%$ % Define expected results.
%$ e.time = [transpose(2000+(1:12)), ones(12,1)];
%$ e.init = dynDate(2001);
%$ e.freq = 1;
%$ e.name = char('A1','A2','B1','B2');
%$ e.name = {'A1';'A2';'B1';'B2'};
%$ e.data = [ [A; NaN(2,2)], [NaN(4,2); B]];
%$
%$ % Instantiate two time series objects.
......@@ -129,7 +130,7 @@ end
%$ ts3 = [ts1,ts2];
%$
%$ % Check the results.
%$ t(1) = dyn_assert(ts3.Time.time,e.time);
%$ t(1) = dyn_assert(ts3.init,e.init);
%$ t(2) = dyn_assert(ts3.freq,e.freq);
%$ t(3) = dyn_assert(ts3.data,e.data);
%$ t(4) = dyn_assert(ts3.name,e.name);
......@@ -142,17 +143,17 @@ end
%$ B = [transpose(5:11),2*transpose(5:11)];
%$
%$ % Define names
%$ A_name = char('A1','A2');
%$ B_name = char('B1','B2');
%$ A_name = {'A1';'A2'};
%$ B_name = {'B1';'B2'};
%$
%$ % Define initial date
%$ A_init = '1950Q1';
%$ B_init = '1950Q3';
%$
%$ % Define expected results.
%$ e.time = [ 1950, 1; 1950, 2; 1950, 3; 1950, 4; 1951, 1; 1951, 2; 1951, 3; 1951, 4; 1952, 1];
%$ e.freq = 4;
%$ e.name = char('A1','A2','B1','B2');
%$ e.init = dynDate('1950Q1');
%$ e.name = {'A1';'A2';'B1';'B2'};
%$ e.data = [ [A; NaN(2,2)], [NaN(2,2); B]];
%$
%$ % Instantiate two time series objects.
......@@ -163,7 +164,7 @@ end
%$ ts3 = [ts1,ts2];
%$
%$ % Check the results.
%$ t(1) = dyn_assert(ts3.Time.time,e.time);
%$ t(1) = dyn_assert(ts3.init,e.init);
%$ t(2) = dyn_assert(ts3.freq,e.freq);
%$ t(3) = dyn_assert(ts3.data,e.data);
%$ t(4) = dyn_assert(ts3.name,e.name);
......@@ -176,17 +177,17 @@ end
%$ B = [transpose(5:9),2*transpose(5:9)];
%$
%$ % Define names
%$ A_name = char('A1','A2');
%$ B_name = char('B1','B2');
%$ A_name = {'A1';'A2'};
%$ B_name = {'B1';'B2'};
%$
%$ % Define initial date
%$ A_init = '1950Q1';
%$ B_init = '1950Q3';
%$
%$ % Define expected results.
%$ e.time = [ 1950, 1; 1950, 2; 1950, 3; 1950, 4; 1951, 1; 1951, 2; 1951, 3];
%$ e.init = dynDate(A_init);
%$ e.freq = 4;
%$ e.name = char('A1','A2','B1','B2');
%$ e.name = {'A1';'A2';'B1';'B2'};
%$ e.data = [ A, [NaN(2,2); B]];
%$
%$ % Instantiate two time series objects.
......@@ -197,7 +198,7 @@ end
%$ ts3 = [ts1,ts2];
%$
%$ % Check the results.
%$ t(1) = dyn_assert(ts3.Time.time,e.time);
%$ t(1) = dyn_assert(ts3.init,e.init);
%$ t(2) = dyn_assert(ts3.freq,e.freq);
%$ t(3) = dyn_assert(ts3.data,e.data);
%$ t(4) = dyn_assert(ts3.name,e.name);
......@@ -211,14 +212,14 @@ end
%$ C = [transpose(1:10),4*transpose(1:10)];
%$
%$ % Define names
%$ A_name = char('A1','A2');
%$ B_name = char('B1','B2');
%$ C_name = char('C1','C2');
%$ A_name = {'A1';'A2'};
%$ B_name = {'B1';'B2'};
%$ C_name = {'C1';'C2'};
%$
%$ % Define expected results.
%$ e.time = [transpose(1:10), ones(10,1)];
%$ e.init = dynDate(1);
%$ e.freq = 1;
%$ e.name = char('A1','A2','B1','B2','C1','C2');
%$ e.name = {'A1';'A2';'B1';'B2';'C1';'C2'};
%$ e.data = [A,B,C];
%$
%$ % Instantiate two time series objects.
......@@ -230,7 +231,7 @@ end
%$ ts4 = [ts1,ts2,ts3];
%$
%$ % Check the results.
%$ t(1) = dyn_assert(ts4.Time.time,e.time);
%$ t(1) = dyn_assert(ts4.init,e.init);
%$ t(2) = dyn_assert(ts4.freq,e.freq);
%$ t(3) = dyn_assert(ts4.data,e.data);
%$ t(4) = dyn_assert(ts4.name,e.name);
......
......@@ -77,31 +77,34 @@ else
end
d_init_flag = 0;
if ~isequal(b.Time(1),c.Time(1))
if ~isequal(b.init,c.init)
d_init_flag = 1;
end
d_last_flag = 0;
if ~isequal(b.Time(end),c.Time(end))
d_last_flag = 1;
end
a.vobs = b.vobs+c.vobs;
a.name = char(b.name,c.name);
a.tex = char(b.tex,c.tex);
a.name = vertcat(b.name,c.name);
a.tex = vertcat(b.tex,c.tex);
if ~( d_nobs_flag(1) || d_init_flag(1) || d_last_flag(1) )
a.Time = b.Time;
if ~( d_nobs_flag(1) || d_init_flag(1) )
a.init = b.init;
a.data = [b.data,c.data];
else
[JUNK,IB] = setdiff(b.Time(:),c.Time(:),'rows');
[JUNK,IC] = setdiff(c.Time(:),b.Time(:),'rows');
[JUNK,JB,JC] = intersect(b.Time(:),c.Time(:),'rows');
a.Time = a.Time.setTime(sortrows([b.Time(IB); b.Time(JB); c.Time(IC)],[1 2]));
a.nobs = rows(a.Time(:));
a.data = NaN(a.nobs,a.vobs);
[junk,ia,ib] = intersect(a.Time(:),b.Time(:),'rows');
a.data(ia,1:b.vobs) = b.data;
[junk,ia,ic] = intersect(a.Time(:),c.Time(:),'rows');
a.data(ia,b.vobs+(1:c.vobs)) = c.data;
if b.init<=c.init
a.init = b.init;
if b.init<c.init
c.data = [NaN(c.init-b.init,c.vobs); c.data];
end
else
a.init = c.init;
b_first_lines = b.init-c.init;
b.data = [NaN(b.init-c.init,b.vobs); b.data];
end
b_last_date = b.init+b.nobs;
c_last_date = c.init+c.nobs;
if b_last_date<c_last_date
b.data = [b.data; NaN(c_last_date-b_last_date,b.vobs)];
elseif b_last_date>c_last_date
c.data = [c.data; NaN(b_last_date-c_last_date,c.vobs)];
end
a.data = [b.data, c.data];
end
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment