From c6d93d686a20be61a487e3c3a80774477591f846 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Adjemian=20=28Charybdis=29?= <stephane.adjemian@univ-lemans.fr> Date: Sun, 8 Jun 2014 17:05:04 +0200 Subject: [PATCH] Added new syntax to remove variables from a dseries object. If ts is a dseries object, then ts{'Variable_1','Variable_2'} = []; or ts{'Variable_@1,2@} = []; will remove Variable_1 and Variable_2 from ts (if they exist). --- matlab/@dseries/subsasgn.m | 34 ++++++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/matlab/@dseries/subsasgn.m b/matlab/@dseries/subsasgn.m index 17fc472cde..b74937812a 100644 --- a/matlab/@dseries/subsasgn.m +++ b/matlab/@dseries/subsasgn.m @@ -77,6 +77,12 @@ switch length(S) end end end + if isempty(B) + for i=1:length(S(1).subs) + A = remove(A,S(1).subs{i}); + end + return + end if ~isequal(length(S(1).subs),B.vobs) error('dseries::subsasgn: Wrong syntax!') end @@ -845,7 +851,7 @@ end %$ T = all(t); %@eof:21 -%@test:21 +%@test:22 %$ % Define a datasets. %$ A = rand(1,3); %$ @@ -867,4 +873,28 @@ end %$ t(4) = dyn_assert(ts.data,repmat(A,4,1),1e-15); %$ end %$ T = all(t); -%@eof:21 \ No newline at end of file +%@eof:22 + +%@test:23 +%$ % Instantiate a dseries object. +%$ ts0 = dseries(randn(10,6), '1999y'); +%$ +%$ % Try to remove Variable_2 and Variable_3 +%$ try +%$ ts0{'Variable_@2,3@'} = []; +%$ t(1) = 1; +%$ catch +%$ t(1) = 0; +%$ end +%$ +%$ if t(1) +%$ % Try to display Variable_2 and Variable_3 again (should fail because already removed) +%$ try +%$ ts0{'Variable_@2,3@'}; +%$ t(2) = 0; +%$ catch +%$ t(2) = 1; +%$ end +%$ end +%$ T = all(t); +%@eof:23 \ No newline at end of file -- GitLab