# HG changeset patch # User paramaniac # Date 1331408787 0 # Node ID dbea4e0ca9575542d8de502854bfbae103bfe93c # Parent 40a1e6b3672660f6d888621578fce41f940c7770 control-devel: use recursion instead of for-loop, fix subsref tsam diff -r 40a1e6b36726 -r dbea4e0ca957 extra/control-devel/inst/@iddata/subsref.m --- a/extra/control-devel/inst/@iddata/subsref.m Sat Mar 10 19:45:06 2012 +0000 +++ b/extra/control-devel/inst/@iddata/subsref.m Sat Mar 10 19:46:27 2012 +0000 @@ -21,35 +21,30 @@ ## Author: Lukas Reichlin ## Created: February 2012 -## Version: 0.1 +## Version: 0.2 function a = subsref (a, s) - if (isempty (s)) - error ("iddata: subsref: missing index"); + if (numel (s) == 0) + return; endif - for k = 1 : numel (s) - if (isa (a, "iddata")) - switch (s(k).type) - case "()" - idx = s(k).subs; - if (numel (idx) > 4) - error ("iddata: subsref: need four or less indices"); - else - a = __dat_prune__ (a, idx{:}); - endif - case "." - fld = s(k).subs; - a = get (a, fld); - otherwise - error ("iddata: subsref: invalid subscript type"); - endswitch - else # not an iddata set - a = subsref (a, s(k:end)); - return; - endif - endfor + switch (s(1).type) + case "()" + idx = s(1).subs; + if (numel (idx) > 4) + error ("iddata: subsref: need four or less indices"); + else + a = __dat_prune__ (a, idx{:}); + endif + case "." + fld = s(1).subs; + a = get (a, fld); + otherwise + error ("iddata: subsref: invalid subscript type"); + endswitch + + a = subsref (a, s(2:end)); endfunction @@ -69,5 +64,6 @@ endif dat.expname = dat.expname(exp_idx); + dat.tsam = dat.tsam(exp_idx); -endfunction \ No newline at end of file +endfunction