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

Added the possibility to extract a dynDate object from a dynDates object.

*Example* If a dynDates object is built as follows

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

then dd(2) is a dynDate object (should be equal to dynDate('1967Q1')).
parent 2dad114e
......@@ -168,21 +168,21 @@ end
%@eof:3
%@test:4
%$ % Define some dates
%$ B1 = '1945Q1';
%$ B2 = '1950Q3';
%$ B3 = '1950M10';
%$ B4 = '1953Q1';
%$ % Define a dynDates object
%$ B = dynDate('1950Q1'):dynDate('1960Q3');
%$
%$
%$ % Call the tested routine.
%$ try
%$ d = dynDates(B1,B2,B3,B4);
%$ t(1) = 0;
%$ T = 0;
%$ catch
%$ % Expected issue...
%$ d = B(2);
%$ if isa(d,'dynDate')
%$ t(1) = 1;
%$ T = 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]);
%$ end
%$ T = all(t);
%@eof:4
\ No newline at end of file
......@@ -69,10 +69,11 @@ if isequal(S(1).type,'.')
error('dynDates::subsref: Unknown public method or member!')
end
elseif isequal(S.type,'()') % Extract a sub-sample.
if length(S.subs)==1
S.subs = [S.subs, ':'];
if isscalar(S.subs) && isint(S.subs{1}) && S.subs{1}>0 && S.subs{1}<A.ndat
B = dynDate(A.time(S.subs{1},:),A.freq);
else
B = builtin('subsref', A.time, S);
end
B = builtin('subsref', A.time, S);
else
error('dynDates::subsref: Something is wrong in your syntax!')
end
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