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).

time-shift
Stéphane Adjemian (Charybdis) 2013-10-11 10:17:48 +02:00
parent 153fe1ca82
commit 049ba8d527
1 changed files with 7 additions and 14 deletions

View File

@ -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!')