From: <par...@us...> - 2012-05-31 13:34:19
|
Revision: 10547 http://octave.svn.sourceforge.net/octave/?rev=10547&view=rev Author: paramaniac Date: 2012-05-31 13:34:10 +0000 (Thu, 31 May 2012) Log Message: ----------- control-devel: return noise inputs e or v if requested Modified Paths: -------------- trunk/octave-forge/extra/control-devel/inst/__slicot_identification__.m Modified: trunk/octave-forge/extra/control-devel/inst/__slicot_identification__.m =================================================================== --- trunk/octave-forge/extra/control-devel/inst/__slicot_identification__.m 2012-05-31 12:31:34 UTC (rev 10546) +++ trunk/octave-forge/extra/control-devel/inst/__slicot_identification__.m 2012-05-31 13:34:10 UTC (rev 10547) @@ -57,7 +57,7 @@ error ("%s: keys and values must come in pairs", method); endif - [ns, l, m, e] = size (dat); # dataset dimensions + [ns, p, m, e] = size (dat); # dataset dimensions tsam = dat.tsam; ## multi-experiment data requires equal sampling times @@ -76,6 +76,7 @@ s = []; n = []; conf = []; + noise = "n" ## handle keys and values for k = 1 : 2 : nkv @@ -95,6 +96,11 @@ rcond = val; case "confirm" conf = logical (val); + case "noise" + noise = val; + % none + % e + % v (normalized) otherwise warning ("%s: invalid property name '%s' ignored", method, key); endswitch @@ -103,7 +109,7 @@ ## handle s/nobr and n nsmp = sum (ns); # total number of samples - nobr = fix ((nsmp+1)/(2*(m+l+1))); + nobr = fix ((nsmp+1)/(2*(m+p+1))); if (e > 1) nobr = min (nobr, fix (min (ns) / 2)); endif @@ -132,9 +138,29 @@ ## 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); + ## L L' = Ry, e = L v, v becomes white noise with identity covariance matrix + l = chol (ry, "lower"); + ## assemble model - sys = ss (a, b, c, d, tsam); + [inname, outname] = get (dat, "inname", "outname"); + if (strncmpi (noise, "e", 1)) + sys = ss (a, [b, k], c, [d, eye(p)], tsam); + in_u = __labels__ (inname, "u"); + in_e = __labels__ (outname, "y"); + in_e = cellfun (@(x) ["e@", x], in_e, "uniformoutput", false); + inname = [in_u; in_e]; + elseif (strncmpi (noise, "v", 1)) + sys = ss (a, [b, k*l], c, [d, l], tsam); + in_u = __labels__ (inname, "u"); + in_v = __labels__ (outname, "y"); + in_v = cellfun (@(x) ["v@", x], in_v, "uniformoutput", false); + inname = [in_u; in_v]; + else + sys = ss (a, b, c, d, tsam); + endif + sys = set (sys, "inname", inname, "outname", outname); + ## return x0 as vector for single-experiment data ## instead of a cell containing one vector if (numel (x0) == 1) @@ -146,8 +172,7 @@ ## state covariance matrix Q ## output covariance matrix Ry ## state-output cross-covariance matrix S - ## L L' = Ry, e = L v, v becomes white noise with identity covariance matrix - info = struct ("K", k, "Q", q, "Ry", ry, "S", s, "L", chol (ry, "lower")); + info = struct ("K", k, "Q", q, "Ry", ry, "S", s, "L", l); endfunction This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |