changeset 9459:0d7439781ee5 octave-forge

control-devel: add subsasgn method to iddata class
author paramaniac
date Tue, 21 Feb 2012 20:48:08 +0000
parents e823bd67d070
children eaf8d8b17162
files extra/control-devel/inst/@iddata/subsasgn.m
diffstat 1 files changed, 40 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/extra/control-devel/inst/@iddata/subsasgn.m	Tue Feb 21 20:48:08 2012 +0000
@@ -0,0 +1,40 @@
+## 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 assignment for LTI objects.
+## Used by Octave for "sys.property = value".
+
+## Author: Lukas Reichlin <lukas.reichlin@gmail.com>
+## Created: February 2012
+## Version: 0.1
+
+function dat = subsasgn (dat, idx, val)
+
+  switch (idx(1).type)
+    case "."
+      if (length (idx) == 1)
+        dat = set (dat, idx.subs, val);
+      else
+        prop = idx(1).subs;
+        dat = set (dat, prop, subsasgn (get (dat, prop), idx(2:end), val));
+      endif
+    otherwise
+      error ("iddata: subsasgn: invalid subscripted assignment type");
+  endswitch
+
+endfunction
\ No newline at end of file