From: <par...@us...> - 2012-05-21 13:40:50
|
Revision: 10474 http://octave.svn.sourceforge.net/octave/?rev=10474&view=rev Author: paramaniac Date: 2012-05-21 13:40:38 +0000 (Mon, 21 May 2012) Log Message: ----------- control-devel: work on identification user functions (2) Modified Paths: -------------- trunk/octave-forge/extra/control-devel/inst/__slicot_identification__.m trunk/octave-forge/extra/control-devel/inst/moen4.m trunk/octave-forge/extra/control-devel/inst/moesp.m trunk/octave-forge/extra/control-devel/inst/n4sid.m Modified: trunk/octave-forge/extra/control-devel/inst/__slicot_identification__.m =================================================================== --- trunk/octave-forge/extra/control-devel/inst/__slicot_identification__.m 2012-05-21 13:03:02 UTC (rev 10473) +++ trunk/octave-forge/extra/control-devel/inst/__slicot_identification__.m 2012-05-21 13:40:38 UTC (rev 10474) @@ -1,5 +1,32 @@ -function [sys, x0] = __slicot_identification__ (method, dat, n = []) +## 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}, @var{x0}] =} __slicot_identification__ (@var{method}, @var{dat}, @dots{}) +## Backend for moesp, moen4 and n4sid. +## @end deftypefn + +## Author: Lukas Reichlin <luk...@gm...> +## Created: May 2012 +## Version: 0.1 + +function [sys, x0] = __slicot_identification__ (method, dat, varargin) + + ## determine identification method switch (method) case "moesp" meth = 0; @@ -10,20 +37,60 @@ otherwise error ("ident: invalid method"); # should never happen endswitch - + if (! isa (dat, "iddata")) error ("%s: first argument must be an 'iddata' dataset", method); endif + + if (nargin > 2) # ident (dat, ...) + if (is_real_scalar (varargin{1})) # ident (dat, n, ...) + varargin = horzcat (varargin(2:end), {"order"}, varargin(1)); + endif + if (isstruct (varargin{1})) # ident (dat, opt, ...), ident (dat, n, opt, ...) + varargin = horzcat (__opt2cell__ (varargin{1}), varargin(2:end)); + endif + endif + + nkv = numel (varargin); # number of keys and values + + if (rem (nkv, 2)) + error ("%s: keys and values must come in pairs", method); + endif + [ns, l, m, e] = size (dat); # dataset dimensions + ## default arguments alg = 0; conct = 1; # no connection between experiments ctrl = 1; # don't confirm order n rcond = 0.0; tol = -1.0; % 0; + s = []; + n = []; - [ns, l, m, e] = size (dat); + ## handle keys and values + for k = 1 : 2 : nkv + key = lower (varargin{k}); + val = varargin{k+1}; + switch (key) + ## TODO: proper argument checking + case {"n", "order"} + n = val; + case "s" + s = val; + case {"alg", "algorithm"} + error ("alg"); + case "tol" + tol = val; + case "rcond" + rcond = val; + otherwise + warning ("%s: invalid property name '%s' ignored", method, key); + endswitch + endfor + + s = min (2*n, n+10); # upper bound for n nsmp = sum (ns); # total number of samples nobr = fix ((nsmp+1)/(2*(m+l+1))); Modified: trunk/octave-forge/extra/control-devel/inst/moen4.m =================================================================== --- trunk/octave-forge/extra/control-devel/inst/moen4.m 2012-05-21 13:03:02 UTC (rev 10473) +++ trunk/octave-forge/extra/control-devel/inst/moen4.m 2012-05-21 13:40:38 UTC (rev 10474) @@ -16,7 +16,10 @@ ## 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}) +## @deftypefn {Function File} {[@var{sys}, @var{x0}] =} moen4 (@var{dat}, @dots{}) +## @deftypefnx {Function File} {[@var{sys}, @var{x0}] =} moen4 (@var{dat}, @var{n}, @dots{}) +## @deftypefnx {Function File} {[@var{sys}, @var{x0}] =} moen4 (@var{dat}, @var{opt}, @dots{}) +## @deftypefnx {Function File} {[@var{sys}, @var{x0}] =} moen4 (@var{dat}, @var{n}, @var{opt}, @dots{}) ## Combined method: MOESP algorithm for finding the ## matrices A and C, and N4SID algorithm for ## finding the matrices B and D. Modified: trunk/octave-forge/extra/control-devel/inst/moesp.m =================================================================== --- trunk/octave-forge/extra/control-devel/inst/moesp.m 2012-05-21 13:03:02 UTC (rev 10473) +++ trunk/octave-forge/extra/control-devel/inst/moesp.m 2012-05-21 13:40:38 UTC (rev 10474) @@ -16,7 +16,10 @@ ## 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}) +## @deftypefn {Function File} {[@var{sys}, @var{x0}] =} moesp (@var{dat}, @dots{}) +## @deftypefnx {Function File} {[@var{sys}, @var{x0}] =} moesp (@var{dat}, @var{n}, @dots{}) +## @deftypefnx {Function File} {[@var{sys}, @var{x0}] =} moesp (@var{dat}, @var{opt}, @dots{}) +## @deftypefnx {Function File} {[@var{sys}, @var{x0}] =} moesp (@var{dat}, @var{n}, @var{opt}, @dots{}) ## MOESP: Multivariable Output Error State sPace. ## @end deftypefn Modified: trunk/octave-forge/extra/control-devel/inst/n4sid.m =================================================================== --- trunk/octave-forge/extra/control-devel/inst/n4sid.m 2012-05-21 13:03:02 UTC (rev 10473) +++ trunk/octave-forge/extra/control-devel/inst/n4sid.m 2012-05-21 13:40:38 UTC (rev 10474) @@ -16,7 +16,10 @@ ## 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}) +## @deftypefn {Function File} {[@var{sys}, @var{x0}] =} n4sid (@var{dat}, @dots{}) +## @deftypefnx {Function File} {[@var{sys}, @var{x0}] =} n4sid (@var{dat}, @var{n}, @dots{}) +## @deftypefnx {Function File} {[@var{sys}, @var{x0}] =} n4sid (@var{dat}, @var{opt}, @dots{}) +## @deftypefnx {Function File} {[@var{sys}, @var{x0}] =} n4sid (@var{dat}, @var{n}, @var{opt}, @dots{}) ## N4SID: Numerical algorithm for Subspace State Space System IDentification. ## @end deftypefn This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |