changeset 10289:ad94a9e3eabe octave-forge

control-devel: handle properties for identification backend
author paramaniac
date Mon, 21 May 2012 15:16:30 +0000
parents 58f4d52330a3
children 2dd7c8168ea0
files extra/control-devel/devel/PowerPlant.m extra/control-devel/inst/__slicot_identification__.m
diffstat 2 files changed, 27 insertions(+), 29 deletions(-) [+]
line wrap: on
line diff
--- a/extra/control-devel/devel/PowerPlant.m	Mon May 21 13:40:38 2012 +0000
+++ b/extra/control-devel/devel/PowerPlant.m	Mon May 21 15:16:30 2012 +0000
@@ -65,7 +65,7 @@
 
 dat = iddata (Y, U, tsam, 'outname', outname, 'inname', inname)
 
-[sys, x0] = ident (dat, 10, 8)     % s=10, n=8
+[sys, x0] = moen4 (dat, 's', 10, 'n', 8)     % s=10, n=8
 
 
 [y, t] = lsim (sys, U, [], x0);
--- a/extra/control-devel/inst/__slicot_identification__.m	Mon May 21 13:40:38 2012 +0000
+++ b/extra/control-devel/inst/__slicot_identification__.m	Mon May 21 15:16:30 2012 +0000
@@ -61,8 +61,8 @@
   
   ## default arguments
   alg = 0;
-  conct = 1;    # no connection between experiments
-  ctrl = 1;     # don't confirm order n
+  conct = 1;                            # no connection between experiments
+  ctrl = 1;                             # don't confirm order n
   rcond = 0.0;
   tol = -1.0; % 0;
   s = [];
@@ -89,49 +89,36 @@
     endswitch
   endfor
   
-    
-  
-  s = min (2*n, n+10);                  # upper bound for n
+
+  ## handle s/nobr and n
   nsmp = sum (ns);                      # total number of samples
   nobr = fix ((nsmp+1)/(2*(m+l+1)));
   if (e > 1)
     nobr = min (nobr, fix (min (ns) / 2));
   endif
-  nobr = min (nobr, s)
-
-%{
   
   if (isempty (s) && isempty (n))
-    nsmp = ns(1);
-    nobr = fix ((nsmp+1)/(2*(m+l+1)));
-    ctrl = 0;  # confirm system order estimate
+    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)));
+    s = min (2*n, n+10);                # upper bound for n
     nobr = min (nobr, s);
-    ctrl = 1;  # no confirmation
   elseif (isempty (n))
-    nobr = s;
-    ctrl = 0;  # confirm system order estimate
+    nobr = __check_s__ (s, nobr, method);
+    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");
+  else                                  # s & n non-empty
+    nobr = __check_s__ (s, nobr, method);
+    if (n >= nobr)
+      error ("%s: n=%d, but require n < %d (s)", method, n, nobr);
     endif
-    nobr = s;
-    ctrl = 1;
-    ## TODO: specify n for IB01BD
   endif
-%}
+
   
+  ## perform system identification
   [a, b, c, d, q, ry, s, k, x0] = slident (dat.y, dat.u, nobr, n, meth, alg, conct, ctrl, rcond, tol);
 
+  ## assemble model
   sys = ss (a, b, c, d, dat.tsam{1});
 
   if (numel (x0) == 1)
@@ -139,3 +126,14 @@
   endif
 
 endfunction
+
+
+function nobr = __check_s__ (s, nobr, method)
+
+  if (s <= nobr)
+    nobr = s;
+  else
+    error ("%s: require upper bound s <= %d, but the requested s is %d", method, nobr, s);
+  endif
+
+endfunction