/usr/share/octave/packages/control-2.6.2/@iddata/resample.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 | ## 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{dat} =} resample (@var{dat}, @var{p}, @var{q})
## @deftypefnx {Function File} {@var{dat} =} resample (@var{dat}, @var{p}, @var{q}, @var{n})
## @deftypefnx {Function File} {@var{dat} =} resample (@var{dat}, @var{p}, @var{q}, @var{h})
## Change the sample rate of the output and input signals in dataset @var{dat}
## by a factor of @code{p/q}. This is performed using a polyphase algorithm.
## The anti-aliasing @acronym{FIR} filter can be specified as follows:
## Either by order @var{n} (scalar) with default value 0. The band edges
## are then chosen automatically. Or by impulse response @var{h} (vector).
## Requires the signal package to be installed.
##
## @strong{Algorithm}@*
## Uses commands @command{fir1} and @command{resample}
## from the signal package.
##
## @strong{References}@*
## [1] J. G. Proakis and D. G. Manolakis,
## Digital Signal Processing: Principles, Algorithms, and Applications,
## 4th ed., Prentice Hall, 2007. Chap. 6
##
## [2] A. V. Oppenheim, R. W. Schafer and J. R. Buck,
## Discrete-time signal processing, Signal processing series,
## Prentice-Hall, 1999
##
## @end deftypefn
## Author: Lukas Reichlin <lukas.reichlin@gmail.com>
## Created: June 2012
## Version: 0.3
function dat = resample (dat, p, q, n = 0)
if (nargin < 3 || nargin > 4)
print_usage ();
endif
## requires signal package
try
pkg load signal;
catch
error ("iddata: resample: please install signal package to proceed");
end_try_catch
if (is_real_scalar (n)) # fourth scalar argument n is the order of the anti-aliasing filter
h = fir1 (n, 1/q);
elseif (is_real_vector (n)) # fourth vector argument is the (impulse response of the) anti-aliasing filter
h = n;
else
error ("iddata: resample: fourth argument invalid");
endif
dat.y = cellfun (@resample, dat.y, {p}, {q}, {h}, "uniformoutput", false);
dat.u = cellfun (@resample, dat.u, {p}, {q}, {h}, "uniformoutput", false);
dat.tsam = cellfun (@sampling_time, dat.tsam, {p}, {q}, "uniformoutput", false);
endfunction
function tsam = sampling_time (tsam, p, q)
if (issample (tsam, 1)) # unspecified sampling times (-1) are left untouched
tsam = (tsam*q)/p;
endif
endfunction
|