/usr/share/octave/packages/signal-1.2.2/wkeep.m is in octave-signal 1.2.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 | ## Copyright (C) 2008 Sylvain Pelissier <sylvain.pelissier@gmail.com>
##
## This program 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.
##
## This program 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
## this program; if not, see <http://www.gnu.org/licenses/>.
## -*- texinfo -*-
## @deftypefn {Function File} {[@var{y}] =} wkeep(@var{x,l,opt})
## Extract the elements of x of size l from the center, the right or the left.
## @end deftypefn
function y = wkeep(x,l,opt = 'c')
if (nargin < 2|| nargin > 3); print_usage; end
if(isvector(x))
if(l > length(x))
error('l must be or equal the size of x');
end
if(opt=='c')
s = (length(x)-l)./2;
y = x(1+floor(s):end-ceil(s));
elseif(opt=='l')
y=x(1:l);
elseif(opt=='r')
y = x(end-l+1:end);
else
error('opt must be equal to c, l or r');
end
else
if(length(l) == 2)
s1 = (length(x)-l(1))./2;
s2 = (length(x)-l(2))./2;
else
error('For a matrix l must be a 1x2 vector');
end
if(nargin==2)
y = x(1+floor(s1):end-ceil(s1),1+floor(s2):end-ceil(s2));
else
if(length(opt) == 2)
firstr=opt(1);
firstc=opt(2);
else
error('For a matrix l must be a 1x2 vector');
end
y=x(firstr:firstr+l(1)-1,firstc:firstc+l(2)-1);
end
end
end
|