changeset 10243:249938380b7a octave-forge

control-devel: subspace identfication
author paramaniac
date Sat, 12 May 2012 19:04:36 +0000
parents 52586f108b57
children cd808d3516dd
files extra/control-devel/inst/__slicot_identification__.m extra/control-devel/inst/arx.m extra/control-devel/inst/moen4.m extra/control-devel/inst/moesp.m extra/control-devel/inst/n4sid.m
diffstat 5 files changed, 174 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/extra/control-devel/inst/__slicot_identification__.m	Sat May 12 19:04:36 2012 +0000
@@ -0,0 +1,57 @@
+function [sys, x0] = __slicot_identification__ (method, dat, s = [], n = [])
+
+  switch (method)
+    case "moesp"
+      meth = 0;
+    case "n4sid"
+      meth = 1;
+    case "moen4"
+      meth = 2;
+    otherwise
+      error ("ident: invalid method");  # should never happen
+  endswitch
+
+%  meth = 2; % 2    % geht: meth/alg  1/1, 
+  alg = 0; % 0     % geht nicht: meth/alg  0/1
+  jobd = 1;
+  batch = 3;
+  conct = 1;
+  ctrl = 0; %1;
+  rcond = 0.0;
+  tol = -1.0; % 0;
+  
+  [ns, l, m, e] = size (dat);
+  
+  if (isempty (s) && isempty (n))
+    nsmp = ns(1);
+    nobr = fix ((nsmp+1)/(2*(m+l+1)));
+    ctrl = 0;  # confirm system order estimate
+    n = 0;
+    % nsmp >= 2*(m+l+1)*nobr - 1
+    % nobr <= (nsmp+1)/(2*(m+l+1))
+  elseif (isempty (s))
+    s = min (2*n, n+10);
+    nsmp = ns(1);
+    nobr = fix ((nsmp+1)/(2*(m+l+1)));
+    nobr = min (nobr, s);
+    ctrl = 1;  # no confirmation
+  elseif (isempty (n))
+    nobr = s;
+    ctrl = 0;  # confirm system order estimate
+    n = 0;
+  else         # s & n non-empty
+    nsmp = ns(1);
+    nobr = fix ((nsmp+1)/(2*(m+l+1)));
+    if (s > nobr)
+      error ("ident: s > nobr");
+    endif
+    nobr = s;
+    ctrl = 1;
+    ## TODO: specify n for IB01BD
+  endif
+  
+  [a, b, c, d, q, ry, s, k, x0] = slident (dat.y{1}, dat.u{1}, nobr, n, meth, alg, jobd, batch, conct, ctrl, rcond, tol);
+
+  sys = ss (a, b, c, d, dat.tsam{1});
+
+endfunction
--- a/extra/control-devel/inst/arx.m	Sat May 12 16:41:38 2012 +0000
+++ b/extra/control-devel/inst/arx.m	Sat May 12 19:04:36 2012 +0000
@@ -1,3 +1,25 @@
+## 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 -*-
+## @deftypefn {Function File} {@var{sys} =} arx (@var{dat}, @var{na}, @var{nb})
+## ARX
+## @end deftypefn
+
 ## Author: Lukas Reichlin <lukas.reichlin@gmail.com>
 ## Created: April 2012
 ## Version: 0.1
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/extra/control-devel/inst/moen4.m	Sat May 12 19:04:36 2012 +0000
@@ -0,0 +1,33 @@
+## 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 -*-
+## @deftypefn {Function File} {@var{dat} =} moen4 (@var{dat}, @var{s}, @var{n})
+## Combined method:  MOESP  algorithm for finding the
+## matrices A and C, and  N4SID  algorithm for
+## finding the matrices B and D.
+## @end deftypefn
+
+## Author: Lukas Reichlin <lukas.reichlin@gmail.com>
+## Created: May 2012
+## Version: 0.1
+
+function [sys, x0] = moen4 (varargin)
+
+  [sys, x0] = __slicot_identification__ ("moen4", varargin{:});
+
+endfunction
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/extra/control-devel/inst/moesp.m	Sat May 12 19:04:36 2012 +0000
@@ -0,0 +1,31 @@
+## 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 -*-
+## @deftypefn {Function File} {@var{dat} =} moesp (@var{dat}, @var{s}, @var{n})
+## MOESP.
+## @end deftypefn
+
+## Author: Lukas Reichlin <lukas.reichlin@gmail.com>
+## Created: May 2012
+## Version: 0.1
+
+function [sys, x0] = moesp (varargin)
+
+  [sys, x0] = __slicot_identification__ ("moesp", varargin{:});
+
+endfunction
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/extra/control-devel/inst/n4sid.m	Sat May 12 19:04:36 2012 +0000
@@ -0,0 +1,31 @@
+## 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 -*-
+## @deftypefn {Function File} {@var{dat} =} n4sid (@var{dat}, @var{s}, @var{n})
+## N4SID.
+## @end deftypefn
+
+## Author: Lukas Reichlin <lukas.reichlin@gmail.com>
+## Created: May 2012
+## Version: 0.1
+
+function [sys, x0] = n4sid (varargin)
+
+  [sys, x0] = __slicot_identification__ ("n4sid", varargin{:});
+
+endfunction
\ No newline at end of file