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

Added the possibility to extract variables from dynSeries object using indices...

Added the possibility to extract variables from dynSeries object using indices instead of variable names.

If ts is a dynSeries object containing variables A1, A2, A3, A4, A5, then the following syntaxes are equivalent:

ts{[1, 2, 5]}

ts{'A1','A2','A5'}

and will create a new dynSeries object made of variables A1, A2 and A5.
parent bc1689fa
...@@ -145,7 +145,25 @@ switch S(1).type ...@@ -145,7 +145,25 @@ switch S(1).type
error('dynSeries::subsref: I have no idea of what you are trying to do!') error('dynSeries::subsref: I have no idea of what you are trying to do!')
end end
case '{}' case '{}'
B = extract(A,S(1).subs{:}); if iscellofchar(S(1).subs)
B = extract(A,S(1).subs{:});
elseif isequal(length(S(1).subs),1) && all(isint(S(1).subs{1}))
idx = S(1).subs{1};
if max(idx)>A.vobs || min(idx)<1
error('dynSeries::subsref: Indices are out of bounds!')
end
B = dynSeries();
B.data = A.data(:,idx);
B.name = A.name(idx);
B.tex = A.tex(idx);
B.nobs = A.nobs;
B.vobs = length(idx);
B.freq = A.freq;
B.init = A.init;
B.time = A.time;
else
error('dynSeries::subsref: What the Hell are you tryin'' to do?!')
end
otherwise otherwise
error('dynSeries::subsref: What the Hell are you doin'' here?!') error('dynSeries::subsref: What the Hell are you doin'' here?!')
end 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