1 ## Copyright (C) 2009, 2010 Lukas F. Reichlin
3 ## This file is part of LTI Syncope.
5 ## LTI Syncope is free software: you can redistribute it and/or modify
6 ## it under the terms of the GNU General Public License as published by
7 ## the Free Software Foundation, either version 3 of the License, or
8 ## (at your option) any later version.
10 ## LTI Syncope is distributed in the hope that it will be useful,
11 ## but WITHOUT ANY WARRANTY; without even the implied warranty of
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 ## GNU General Public License for more details.
15 ## You should have received a copy of the GNU General Public License
16 ## along with LTI Syncope. If not, see <http://www.gnu.org/licenses/>.
19 ## @deftypefn {Function File} {@var{est} =} estim (@var{sys}, @var{l})
20 ## @deftypefnx {Function File} {@var{est} =} estim (@var{sys}, @var{l}, @var{sensors}, @var{known})
21 ## Return state estimator for a given estimator gain.
28 ## State feedback matrix.
30 ## Indices of measured output signals y from @var{sys}. If omitted, all outputs are measured.
32 ## Indices of known input signals u (deterministic) to @var{sys}. All other inputs to @var{sys}
33 ## are assumed stochastic. If argument @var{known} is omitted, no inputs u are known.
39 ## State-space model of estimator.
41 ## @seealso{kalman, place}
44 ## Author: Lukas Reichlin <lukas.reichlin@gmail.com>
45 ## Created: November 2009
48 function est = estim (sys, l, sensors = [], known = [])
50 if (nargin < 2 || nargin > 4)
54 if (! isa (sys, "lti"))
55 error ("estim: first argument must be an LTI system");
58 [a, b, c, d, e, tsam] = dssdata (sys, []);
60 if (isempty (sensors))
61 sensors = 1 : rows (c);
70 d = d(sensors, known);
75 j = [d, zeros(p, p); zeros(n, m), zeros(n, p)];
78 est = dss (f, g, h, j, e, tsam);
80 ## TODO: inname, stname, outname
86 %! sys = ss (-2, 1, 1, 3);
87 %! est = estim (sys, 5);
88 %! [a, b, c, d] = ssdata (est);
90 %! m_exp = [-7, 5; 1, 0; 1, 0];
91 %!assert (m, m_exp, 1e-4);
94 %! sys = ss (-1, 2, 3, 4);
95 %! est = estim (sys, 5);
96 %! [a, b, c, d] = ssdata (est);
98 %! m_exp = [-16, 5; 3, 0; 1, 0];
99 %!assert (m, m_exp, 1e-4);