]> Creatis software - CreaPhase.git/blob - octave_packages/control-2.3.52/__adjust_ss_data__.m
Add a useful package (from Source forge) for octave
[CreaPhase.git] / octave_packages / control-2.3.52 / __adjust_ss_data__.m
1 ## Copyright (C) 2010   Lukas F. Reichlin
2 ##
3 ## This file is part of LTI Syncope.
4 ##
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.
9 ##
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.
14 ##
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/>.
17
18 ## -*- texinfo -*-
19 ## Common code for adjusting SS model data.
20 ## Used by @ss/ss.m, others possibly follow.
21
22 ## Author: Lukas Reichlin <lukas.reichlin@gmail.com>
23 ## Created: October 2010
24 ## Version: 0.1
25
26 function [a, b, c, d, tsam] = __adjust_ss_data__ (a, b, c, d, tsam);
27
28   if (isempty (a))                 # static system
29     a = [];                        # avoid [](nx0) or [](0xn)
30     tsam = -2;
31   endif
32
33   if (isempty (d))
34     if (isempty (c))               # ss (a, b), ss (a, b, [], [], ...)
35       c = eye (size (a));
36       d = zeros (rows (a), columns (b));
37     else                           # ss (a, b, c), ss (a, b, c, [], ...)
38       d = zeros (rows (c), columns (b));
39     endif
40   endif
41
42   if (isempty (b) && isempty (c))  # sys = ss ([], [], [], d)
43     b = zeros (0, columns (d));
44     c = zeros (rows(d), 0);
45     tsam = -2;
46   endif
47
48 endfunction