/usr/share/octave/packages/control-2.6.2/@iddata/set.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 | ## 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} {} set (@var{dat})
## @deftypefnx {Function File} {} set (@var{dat}, @var{"property"}, @var{value}, @dots{})
## @deftypefnx {Function File} {@var{dat} =} set (@var{dat}, @var{"property"}, @var{value}, @dots{})
## Set or modify properties of iddata objects.
## If no return argument @var{dat} is specified, the modified @acronym{LTI} object is stored
## in input argument @var{dat}. @command{set} can handle multiple properties in one call:
## @code{set (dat, 'prop1', val1, 'prop2', val2, 'prop3', val3)}.
## @code{set (dat)} prints a list of the object's property names.
## @end deftypefn
## Author: Lukas Reichlin <lukas.reichlin@gmail.com>
## Created: February 2012
## Version: 0.1
function retdat = set (dat, varargin)
if (nargin == 1) # set (dat), dat = set (dat)
[props, vals] = __property_names__ (dat);
nrows = numel (props);
str = strjust (strvcat (props), "right");
str = horzcat (repmat (" ", nrows, 1), str, repmat (": ", nrows, 1), strvcat (vals));
disp (str);
if (nargout != 0) # function dat = set (dat, varargin)
retdat = dat; # would lead to unwanted output when using
endif # set (dat)
else # set (dat, "prop1", val1, ...), dat = set (dat, "prop1", val1, ...)
if (rem (nargin-1, 2))
error ("iddata: set: properties and values must come in pairs");
endif
[n, p, m, e] = size (dat);
for k = 1 : 2 : (nargin-1)
prop = lower (varargin{k});
val = varargin{k+1};
switch (prop)
case {"y", "outdata", "outputdata", "outd", "outputd"}
val = __adjust_iddata__ (val, dat.u);
[pval, ~, eval] = __iddata_dim__ (val, dat.u);
if (pval != p)
error ("iddata: set: argument has %d instead of %d outputs", pval, p);
endif
if (eval != e) # iddata_dim is not sufficient if dat.u = []
error ("iddata: set: argument has %d instead of %d experiments", eval, e);
endif
dat.y = val;
case {"u", "indata", "inputdata", "ind", "inputd"}
[~, val] = __adjust_iddata__ (dat.y, val);
[~, mval] = __iddata_dim__ (dat.y, val);
if (mval != m)
error ("iddata: set: argument has %d instead of %d inputs", mval, m);
endif
dat.u = val;
case {"outname", "outputname", "outn", "outputn"}
dat.outname = __adjust_labels__ (val, p);
case {"inname", "inputname", "inn", "inputn"}
dat.inname = __adjust_labels__ (val, m);
case {"outunit", "outputunit", "outu", "outputu"}
dat.outunit = __adjust_labels__ (val, p);
case {"inunit", "inputunit", "inu", "inputu"}
dat.inunit = __adjust_labels__ (val, m);
case {"timeunit", "timeu"}
if (ischar (val))
dat.timeunit = val;
else
error ("iddata: set: property 'timeunit' requires a string");
endif
case {"expname", "experimentname", "expn", "experimentn"}
dat.expname = __adjust_labels__ (val, e);
case {"tsam", "ts"}
dat.tsam = __adjust_iddata_tsam__ (val, e);
case {"w", "frequency"}
if (! iscell (val))
val = {val};
endif
if (any (cellfun (@(w) ! isempty (w) && (! is_real_vector (w) || any (w < 0) ...
|| ! issorted (w) || w(1) > w(end) ...
|| length (unique (w)) != length (w)), val)))
error ("iddata: set: w must be a vector of positive real values in ascending order");
endif
dat.w = val;
dat.timedomain = false;
case "name"
if (ischar (val))
sys.name = val;
else
error ("iddata: set: property 'name' requires a string");
endif
case "notes"
if (iscellstr (val))
sys.notes = val;
elseif (ischar (val))
sys.notes = {val};
else
error ("lti: set: property 'notes' requires string or cell of strings");
endif
case "userdata"
sys.userdata = val;
otherwise
error ("iddata: set: invalid property name '%s'", varargin{k});
endswitch
endfor
if (nargout == 0) # set (dat, "prop1", val1, ...)
assignin ("caller", inputname (1), dat);
else # dat = set (dat, "prop1", val1, ...)
retdat = dat;
endif
endif
endfunction
|