/usr/share/octave/packages/control-2.6.2/@ss/ss.m is in octave-control 2.6.2-1build1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 | ## Copyright (C) 2009-2014 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} =} ss (@var{sys})
## @deftypefnx {Function File} {@var{sys} =} ss (@var{d})
## @deftypefnx {Function File} {@var{sys} =} ss (@var{a}, @var{b})
## @deftypefnx {Function File} {@var{sys} =} ss (@var{a}, @var{b}, @var{c})
## @deftypefnx {Function File} {@var{sys} =} ss (@var{a}, @var{b}, @var{c}, @var{d}, @dots{})
## @deftypefnx {Function File} {@var{sys} =} ss (@var{a}, @var{b}, @var{c}, @var{d}, @var{tsam}, @dots{})
## Create or convert to state-space model.
##
## @strong{Inputs}
## @table @var
## @item sys
## @acronym{LTI} model to be converted to state-space.
## @item a
## State matrix (n-by-n).
## @item b
## Input matrix (n-by-m).
## @item c
## Output matrix (p-by-n).
## If @var{c} is empty @code{[]} or not specified, an identity matrix is assumed.
## @item d
## Feedthrough matrix (p-by-m).
## If @var{d} is empty @code{[]} or not specified, a zero matrix is assumed.
## @item tsam
## Sampling time in seconds. If @var{tsam} is not specified, a continuous-time model is assumed.
## @item @dots{}
## Optional pairs of properties and values.
## Type @command{set (ss)} for more information.
## @end table
##
## @strong{Outputs}
## @table @var
## @item sys
## State-space model.
## @end table
##
## @strong{Option Keys and Values}
## @table @var
## @item 'a', 'b', 'c', 'd', 'e'
## State-space matrices. See 'Inputs' for details.
##
## @item 'stname'
## The name of the states in @var{sys}.
## Cell vector containing strings for each state.
## Default names are @code{@{'x1', 'x2', ...@}}
##
## @item 'scaled'
## Logical. If set to true, no automatic scaling is used,
## e.g. for frequency response plots.
##
## @item 'tsam'
## Sampling time. See 'Inputs' for details.
##
## @item 'inname'
## The name of the input channels in @var{sys}.
## Cell vector of length m containing strings.
## Default names are @code{@{'u1', 'u2', ...@}}
##
## @item 'outname'
## The name of the output channels in @var{sys}.
## Cell vector of length p containing strings.
## Default names are @code{@{'y1', 'y2', ...@}}
##
## @item 'ingroup'
## Struct with input group names as field names and
## vectors of input indices as field values.
## Default is an empty struct.
##
## @item 'outgroup'
## Struct with output group names as field names and
## vectors of output indices as field values.
## Default is an empty struct.
##
## @item 'name'
## String containing the name of the model.
##
## @item 'notes'
## String or cell of string containing comments.
##
## @item 'userdata'
## Any data type.
## @end table
##
## @strong{Example}
## @example
## @group
## octave:1> a = [1 2 3; 4 5 6; 7 8 9];
## octave:2> b = [10; 11; 12];
## octave:3> stname = @{"V", "A", "kJ"@};
## octave:4> sys = ss (a, b, [], [], "stname", stname)
## @end group
## @end example
##
## @example
## @group
## sys.a =
## V A kJ
## V 1 2 3
## A 4 5 6
## kJ 7 8 9
## @end group
## @end example
##
## @example
## @group
## sys.b =
## u1
## V 10
## A 11
## kJ 12
## @end group
## @end example
##
## @example
## @group
## sys.c =
## V A kJ
## y1 1 0 0
## y2 0 1 0
## y3 0 0 1
## @end group
## @end example
##
## @example
## @group
## sys.d =
## u1
## y1 0
## y2 0
## y3 0
##
## Continuous-time model.
## octave:5>
## @end group
## @end example
##
## @seealso{tf, dss}
## @end deftypefn
## Author: Lukas Reichlin <lukas.reichlin@gmail.com>
## Created: September 2009
## Version: 0.3
function sys = ss (a = [], b = [], c = [], d = [], varargin)
## model precedence: frd > ss > zpk > tf > double
## inferiorto ("frd");
superiorto ("zpk", "tf", "double");
argc = 0; # initialize argument count
tsam = 0; # initialize sampling time
if (nargin == 1)
if (isa (a, "ss")) # already in ss form sys = ss (sssys)
sys = a;
return;
elseif (isa (a, "lti")) # another lti object sys = ss (sys)
[sys, alti] = __sys2ss__ (a);
sys.lti = alti; # preserve lti properties
return;
elseif (is_real_matrix (a)) # static gain sys = ss (5), sys = ss (matrix)
d = a;
a = [];
else
print_usage ();
endif
elseif (nargin > 4) # default case sys = ss (a, b, c, d, "prop1", val1, ...)
argc = numel (varargin); # number of additional arguments after d
if (issample (varargin{1}, -10)) # sys = ss (a, b, c, d, tsam, "prop1, "val1", ...)
tsam = varargin{1}; # sampling time, could be 0 as well
argc--; # tsam is not a property-value pair
if (argc > 0) # if there are any properties and values ...
varargin = varargin(2:end); # remove tsam from property-value list
endif
endif
endif # nothing to do for ss (), ss (a, b), ss (a, b, c), ss (a, b, c, d)
[a, b, c, d, tsam] = __adjust_ss_data__ (a, b, c, d, tsam);
[p, m, n] = __ss_dim__ (a, b, c, d); # determine number of outputs, inputs and states
stname = repmat ({""}, n, 1); # cell with empty state names
ssdata = struct ("a", a, "b", b,
"c", c, "d", d,
"e", [],
"stname", {stname},
"scaled", false); # struct for ss-specific data
ltisys = lti (p, m, tsam); # parent class for general lti data
sys = class (ssdata, "ss", ltisys); # create ss object
if (argc > 0) # if there are any properties and values, ...
sys = set (sys, varargin{:}); # use the general set function
endif
endfunction
|