From 049ba8d527db65cf45520079b4df609030e5a713 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Adjemian=20=28Charybdis=29?= Date: Fri, 11 Oct 2013 10:17:48 +0200 Subject: [PATCH] Changed @dynDates/subsref so that the selection of a single element in a dynDates object returns a dynDates object with one element (not a dynDate object). --- matlab/@dynDates/subsref.m | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/matlab/@dynDates/subsref.m b/matlab/@dynDates/subsref.m index fab2cce03..df4ce8fe9 100644 --- a/matlab/@dynDates/subsref.m +++ b/matlab/@dynDates/subsref.m @@ -73,21 +73,14 @@ switch S(1).type error('dynDates::subsref: Unknown public member or method!') end case '()' - if isscalar(S(1).subs{1}) - if isint(S(1).subs{1}) && S(1).subs{1}>0 && S(1).subs{1}<=A.ndat - B = dynDate(A.time(S(1).subs{1},:),A.freq); - else - error(['dynDates::subsref: the index has to be a positive integer less than or equal to ' int2str(A.ndat) '!']) - end + % Extract some dates. + if isvector(S(1).subs{1}) && all(isint(S(1).subs{1})) && all(S(1).subs{1}>0) && all(S(1).subs{1}<=A.ndat) + B = dynDates(); + B.freq = A.freq; + B.time = A.time(S(1).subs{1},:); + B.ndat = length(S(1).subs{1}); else - if isvector(S(1).subs{1}) && all(isint(S(1).subs{1})) && all(S(1).subs{1}>0) && all(S(1).subs{1}<=A.ndat) - B = dynDates(); - B.freq = A.freq; - B.time = A.time(S(1).subs{1},:); - B.ndat = length(S(1).subs{1}); - else - error(['dynDates::subsref: indices has to be a vector of positive integers less than or equal to ' int2str(A.ndat) '!']) - end + error(['dynDates::subsref: indices has to be a vector of positive integers less than or equal to ' int2str(A.ndat) '!']) end otherwise error('dynDates::subsref: Something is wrong in your syntax!')