From: <par...@us...> - 2012-02-21 20:38:54
|
Revision: 9643 http://octave.svn.sourceforge.net/octave/?rev=9643&view=rev Author: paramaniac Date: 2012-02-21 20:38:43 +0000 (Tue, 21 Feb 2012) Log Message: ----------- control-devel: add subsref method to iddata class Modified Paths: -------------- trunk/octave-forge/extra/control-devel/inst/@iddata/__property_names__.m trunk/octave-forge/extra/control-devel/inst/@iddata/display.m trunk/octave-forge/extra/control-devel/inst/@iddata/get.m trunk/octave-forge/extra/control-devel/inst/@iddata/iddata.m trunk/octave-forge/extra/control-devel/inst/@iddata/set.m Added Paths: ----------- trunk/octave-forge/extra/control-devel/inst/@iddata/subsref.m Modified: trunk/octave-forge/extra/control-devel/inst/@iddata/__property_names__.m =================================================================== --- trunk/octave-forge/extra/control-devel/inst/@iddata/__property_names__.m 2012-02-21 19:27:53 UTC (rev 9642) +++ trunk/octave-forge/extra/control-devel/inst/@iddata/__property_names__.m 2012-02-21 20:38:43 UTC (rev 9643) @@ -35,7 +35,7 @@ "inunit"; "tsam"; "timeunit"; - "exname"; + "expname"; "name"; "notes"; "userdata"}; Modified: trunk/octave-forge/extra/control-devel/inst/@iddata/display.m =================================================================== --- trunk/octave-forge/extra/control-devel/inst/@iddata/display.m 2012-02-21 19:27:53 UTC (rev 9642) +++ trunk/octave-forge/extra/control-devel/inst/@iddata/display.m 2012-02-21 20:38:43 UTC (rev 9643) @@ -27,7 +27,7 @@ datname = inputname (1); [outname, p] = __labels__ (dat.outname, "y"); [inname, m] = __labels__ (dat.inname, "u"); - [exname, e] = __labels__ (dat.exname, "exp"); + [expname, e] = __labels__ (dat.expname, "exp"); [n, p, m, e] = size (dat); @@ -40,7 +40,7 @@ disp (str); disp (""); - disp (__col2str__ (exname, "Experiment")); + disp (__col2str__ (expname, "Experiment")); disp (""); disp (__col2str__ (outname, "Outputs")); disp (""); @@ -48,7 +48,7 @@ disp (""); %{ - str = strjust (strvcat (exname), "left"); + str = strjust (strvcat (expname), "left"); space = (repmat (" ", e, 1)); str = [space, str]; %} Modified: trunk/octave-forge/extra/control-devel/inst/@iddata/get.m =================================================================== --- trunk/octave-forge/extra/control-devel/inst/@iddata/get.m 2012-02-21 19:27:53 UTC (rev 9642) +++ trunk/octave-forge/extra/control-devel/inst/@iddata/get.m 2012-02-21 20:38:43 UTC (rev 9643) @@ -54,8 +54,8 @@ val = dat.tsam; case {"timeunit"} val = dat.timeunit - case {"exname", "experimentname"} - val = dat.exname; + case {"expname", "experimentname"} + val = dat.expname; case "name" val = dat.name; case "notes" Modified: trunk/octave-forge/extra/control-devel/inst/@iddata/iddata.m =================================================================== --- trunk/octave-forge/extra/control-devel/inst/@iddata/iddata.m 2012-02-21 19:27:53 UTC (rev 9642) +++ trunk/octave-forge/extra/control-devel/inst/@iddata/iddata.m 2012-02-21 20:38:43 UTC (rev 9643) @@ -75,12 +75,12 @@ outname = repmat ({""}, p, 1); inname = repmat ({""}, m, 1); - exname = repmat ({""}, e, 1); + expname = repmat ({""}, e, 1); dat = struct ("y", {y}, "outname", {outname}, "outunit", {outname}, "u", {u}, "inname", {inname}, "inunit", {inname}, "tsam", tsam, "timeunit", {""}, - "exname", {exname}, + "expname", {expname}, "name", "", "notes", {{}}, "userdata", []); dat = class (dat, "iddata"); Modified: trunk/octave-forge/extra/control-devel/inst/@iddata/set.m =================================================================== --- trunk/octave-forge/extra/control-devel/inst/@iddata/set.m 2012-02-21 19:27:53 UTC (rev 9642) +++ trunk/octave-forge/extra/control-devel/inst/@iddata/set.m 2012-02-21 20:38:43 UTC (rev 9643) @@ -79,8 +79,8 @@ dat.tsam; case {"timeunit"} dat.timeunit - case {"exname", "experimentname"} - dat.exname = __adjust_labels__ (val, e); + case {"expname", "experimentname"} + dat.expname = __adjust_labels__ (val, e); case {"tsam", "ts"} if (issample (val, -1)) Added: trunk/octave-forge/extra/control-devel/inst/@iddata/subsref.m =================================================================== --- trunk/octave-forge/extra/control-devel/inst/@iddata/subsref.m (rev 0) +++ trunk/octave-forge/extra/control-devel/inst/@iddata/subsref.m 2012-02-21 20:38:43 UTC (rev 9643) @@ -0,0 +1,73 @@ +## Copyright (C) 2012 Lukas F. Reichlin +## +## This file is part of LTI Syncope. +## +## LTI Syncope is free software: you can redistribute it and/or modify +## it under the terms of the GNU General Public License as published by +## the Free Software Foundation, either version 3 of the License, or +## (at your option) any later version. +## +## LTI Syncope is distributed in the hope that it will be useful, +## but WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +## GNU General Public License for more details. +## +## You should have received a copy of the GNU General Public License +## along with LTI Syncope. If not, see <http://www.gnu.org/licenses/>. + +## -*- texinfo -*- +## Subscripted reference for LTI objects. +## Used by Octave for "sys = sys(2:4, :)" or "val = sys.prop". + +## Author: Lukas Reichlin <luk...@gm...> +## Created: February 2012 +## Version: 0.1 + +function a = subsref (a, s) + + if (isempty (s)) + error ("iddata: subsref: missing index"); + 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 + +endfunction + + +function dat = __dat_prune__ (dat, spl_idx = ":", out_idx = ":", in_idx = ":", exp_idx = ":") + + dat.y = dat.y(exp_idx); + dat.y = cellfun (@(y) y(spl_idx, out_idx), dat.y, "uniformoutput", false); + dat.outname = dat.outname(out_idx); + dat.outunit = dat.outunit(out_idx); + + if (! isempty (dat.u)) + dat.u = dat.u(exp_idx); + dat.u = cellfun (@(u) u(spl_idx, in_idx), dat.u, "uniformoutput", false); + dat.inname = dat.inname(in_idx); + dat.inunit = dat.inunit(in_idx); + endif + + dat.expname = dat.expname(exp_idx); + +endfunction \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |