This file is indexed.

/usr/share/octave/packages/control-3.0.0/fitfrd.m is in octave-control 3.0.0-5.

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
## Copyright (C) 2009-2015   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}, @var{n}] =} fitfrd (@var{dat}, @var{n})
## @deftypefnx{Function File} {[@var{sys}, @var{n}] =} fitfrd (@var{dat}, @var{n}, @var{flag})
## Fit frequency response data with a state-space system.
## If requested, the returned system is stable and minimum-phase.
##
## @strong{Inputs}
## @table @var
## @item dat
## @acronym{LTI} model containing frequency response data of a SISO system.
## @item n
## The desired order of the system to be fitted.  @code{n <= length(dat.w)}.
## @item flag
## The flag controls whether the returned system is stable and minimum-phase.
## @table @var
## @item 0
## The system zeros and poles are not constrained.  Default value.
## @item 1
## The system zeros and poles will have negative real parts in the
## continuous-time case, or moduli less than 1 in the discrete-time case.
## @end table
## @end table
##
## @strong{Outputs}
## @table @var
## @item sys
## State-space model of order @var{n}, fitted to frequency response data @var{dat}.
## @item n
## The order of the obtained system.  The value of @var{n}
## could only be modified if inputs @code{n > 0} and @code{flag = 1}.
## @end table
##
## @strong{Algorithm}@*
## Uses SLICOT SB10YD by courtesy of
## @uref{http://www.slicot.org, NICONET e.V.}
## @end deftypefn

## Author: Lukas Reichlin <lukas.reichlin@gmail.com>
## Created: October 2011
## Version: 0.1

function [sys, n] = fitfrd (dat, n, flag = 0)

  if (nargin == 0 || nargin > 3)
    print_usage ();
  endif
  
  if (! isa (dat, "frd"))
    dat = frd (dat);
  endif

  if (! issiso (dat))
    error ("fitfrd: require SISO system");
  endif

  if (! issample (n, 0) || n != round (n))
    error ("fitfrd: second argument must be an integer >= 0");
  endif

  [H, w, tsam] = frdata (dat, "vector");
  dt = isdt (dat);
  
  if (n > length (w))
    error ("fitfrd: require n <= length (dat.w)");
  endif
  
  [a, b, c, d, n] = __sl_sb10yd__ (real (H), imag (H), w, n, dt, logical (flag));
  
  sys = ss (a, b, c, d, tsam);

endfunction


%!shared Yo, Ye
%! SYS = ss (-1, 1, 1, 0);
%! T = 0:0.1:50;
%! Ye = step (SYS, T);
%! W = logspace (-2, 2, 100);
%! FR = frd (SYS, W);
%! N = 1;
%! SYSID = fitfrd (FR, N, 1);
%! Yo = step (SYSID, T);
%!assert (Yo, Ye, 1e-2);