Commit 6d86ed7c authored by Stéphane Adjemian's avatar Stéphane Adjemian
Browse files

Added the possibility to create a sub dynDates object. Added unitary test.

*Example* Let dd be a dynDate object:

d1 = dynDate('1966Q4');
d2 = dynDate('2013Q1');
dd = d1:d2;

then dd(2:5) is also dynDates object for the dates 1967Q1, 1967Q2, 1967Q3 and 1967Q5.
parent 44440755
......@@ -76,8 +76,36 @@ elseif isequal(S.type,'()') %
error('dynDates::subsref: Something is wrong in your syntax!')
end
else
B = builtin('subsref', A.time, S);
if all(isint(S.subs{1})) && all(S.subs{1}>0) && all(S.subs{1}<A.ndat)
B = dynDates();
B.freq = A.freq;
B.time = A.time(S.subs{1},:);
B.ndat = length(S.subs{1});
else
error('dynDates::subsref: Something is wrong in your syntax!')
end
end
else
error('dynDates::subsref: Something is wrong in your syntax!')
end
\ No newline at end of file
end
%@test:1
%$ % Define a dynDates object
%$ B = dynDate('1950Q1'):dynDate('1960Q3');
%$
%$ % Try to extract a sub-dynDates object.
%$ d = B(2:3);
%$
%$ if isa(d,'dynDates')
%$ t(1) = 1;
%$ else
%$ t(1) = 0;
%$ end
%$
%$ if t(1)
%$ t(2) = dyn_assert(d.freq,B.freq);
%$ t(3) = dyn_assert(d.time,[1950 2; 1950 3]);
%$ t(4) = dyn_assert(d.ndat,2);
%$ end
%$ T = all(t);
%@eof:1
\ 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